ArtisanKit.Control is the workhorse of the module. It handles features like automatic double-buffering, high resolution, appearance state, focus rings, and simple animation.


Event AnimationStep (Key As String, Value As Double, Finished As Boolean)

After having started an animation, this event will fire as necessary to instruct the control the value being animated as changed. For example, animating a value from 1.0 to 2.0 might fire the event 10 times: 1.1, 1.2, 1.3, etc. The Finished parameter is true on the final step of the animation.

Event MouseWheel (MouseX As Integer, MouseY As Integer, PixelsX As Integer, PixelsY As Integer, WheelData As ArtisanKit.ScrollEvent) As Boolean

Based on the built-in MouseWheel event, this version automatically uses pixels instead of lines. PixelsX and PixelsY will set to the number of pixels that should be adjusted, instead of the traditional DeltaX and DeltaY which describe the number of lines that should be adjusted.

The WheelData parameter is an instance of ArtisanKit.ScrollEvent which contains additional details about the scrolling action. Usage of this object is completely optional, but does provide the information necessary to implement "snap-back" scrolling that is now familiar to OS X and iOS.

Event Paint (G As Graphics, Areas() As REALbasic.Rect, Highlighted As Boolean)

The additional Highlighted parameter will be true when the control should be drawn in the foreground/active window.


Animated As Boolean = True

When False animations triggered with StartAnimation finish immediately.

HasFocus As Boolean = False

Indicates wether or not the control has the focus. Setting to True will grab the focus, setting to False pushes the focus to the parent window.

NeedsFullKeyboardAccessForFocus As Boolean = True

Some controls, such as text fields, should be able to get the focus without the user's Full Keyboard Access being enabled. Other controls, such as check boxes, should only get the focus if Full Keyboard Access is enabled. Set to false to accept focus even if Full Keyboard Access is disabled.

ScrollSpeed As Integer = 20

The number of pixels a single "step" of a traditional scroll wheel should move the content. This value is identical to the ScrollBar.LineHeight property.


Protected Sub CancelAnimation (Key As String, Finish As Boolean = False)

Stops the animation with key Key. If Finish is True, a final AnimationStep event will be triggered with the ending value. Otherwise, the value will remain in its last state.

Function Render (Width As Integer, Height As Integer, Highlighted As Boolean = True, MinScale As Double = 1.0, MaxScale As Double = 3.0) As Picture

Creates a multi-resolution Picture object with the control drawn at the given Width and Height. The Highlighted parameter can be used to control wether or not the control is drawn in the foreground. The MinScale and MaxScale parameters are used to control the number of resolutions included in the picture. This will fire multiple Paint events if necessary.

Protected Sub StartAnimation (Key As String, StartValue As Double, EndValue As Double, Duration As Double, Ease As Boolean = True)

Begin an animation. Key is used to identify multiple animations to prevent collisions. StartValue is the value to begin animating from, EndValue is the value to animate to. Duration is the number of seconds the animation should require to complete. If the Ease parameter is true, the animation will have a slight weight to it. It will start faster and slow down towards the end. If Ease is false, the rate of animation will be steady.


The Graphics property will always return Nil. It is impossible to try to draw to the control from outside the Paint event.

Invalidate, Refresh, and RefreshRect will always use an EraseBackground value of False no matter what is passed to them. EraseBackground causes flicker, so it cannot be used.

See Also