Info on VBA events for controls
BeforeDropOrPaste Event
=======================
                        

Occurs when the user is about to drop or paste data onto an object.

Syntax

For Frame
Private Sub object_BeforeDropOrPaste( ByVal Cancel As MSForms.ReturnBoolean, ctrl As Control, ByVal Action As fmAction, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

For MultiPage
Private Sub object_BeforeDropOrPaste( index As Long, ByVal Cancel As MSForms.ReturnBoolean, ctrl As Control, ByVal Action As fmAction, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

For TabStrip
Private Sub object_BeforeDropOrPaste( index As Long, ByVal Cancel As MSForms.ReturnBoolean, ByVal Action As fmAction, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

For other controls
Private Sub object_BeforeDropOrPaste( ByVal Cancel As MSForms.ReturnBoolean, ByVal Action As fmAction, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

The BeforeDropOrPaste event syntax has these parts:

Part Description 
object Required. A valid object name. 
index Required. The index of the Page in a MultiPage that the drop or paste operation will affect. 
Cancel Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event. 
ctrl Required. The target control. 
Action Required. Indicates the result, based on the current keyboard settings, of the pending drag-and-drop operation. 
Data Required. Data that is dragged in a drag-and-drop operation. The data is packaged in a DataObject. 
X, Y Required. The horizontal and vertical position of the mouse pointer when the drop occurs. Both coordinates are measured in points. X is measured from the left edge of the control; Y is measured from the top of the control.. 
Effect Required. Effect of the drag-and-drop operation on the target control. 
Shift Required. Specifies the state of SHIFT, CTRL, and ALT. 


Settings

The settings for Action are: 

Constant Value Description 
fmActionPaste 2 Pastes the selected object into the drop target. 
fmActionDragDrop 3 Indicates the user has dragged the object from its source to the drop target and dropped it on the drop target. 


The settings for Effect are: 

Constant Value Description 
fmDropEffectNone 0 Does not copy or move the drop source to the drop target. 
fmDropEffectCopy 1 Copies the drop source to the drop target. 
fmDropEffectMove 2 Moves the drop source to the drop target. 
fmDropEffectCopyOrMove  3 Copies or moves the drop source to the drop target. 


The settings for Shift are: 

Constant Value Description 
fmShiftMask 1 SHIFT was pressed. 
fmCtrlMask 2 CTRL was pressed. 
fmAltMask 4 ALT was pressed. 


Remarks

For a MultiPage or TabStrip, Visual Basic for Applications initiates this event when it transfers a data object to the control.

For other controls, the system initiates this event immediately prior to the drop or paste operation.

When a control handles this event, you can update the Action argument to identify the drag-and-drop action to perform. When Effect is set to fmDropEffectCopyOrMove, you can assign Action to fmDropEffectNone, fmDropEffectCopy, or fmDropEffectMove. When Effect is set to fmDropEffectCopy or fmDropEffectMove, you can reassign Action to fmDropEffectNone. You cannot reassign Action when Effect is set to fmDropEffectNone.

DropButtonClick Event
=====================                        

Occurs whenever the drop-down list appears or disappears.

Syntax

Private Sub object_DropButtonClick( )

The DropButtonClick event syntax has these parts:


Part Description 
object Required. A valid object. 


Remarks

You can initiate the DropButtonClick event through code or by taking certain actions in the user interface.

In code, calling the DropDown method initiates the DropButtonClick event.

In the user interface, any of the following actions initiates the event: 

Clicking the drop-down button on the control.


Pressing F4. 
Any of the above actions, in code or in the interface, cause the drop-down box to appear on the control. The system initiates the DropButtonClick event when the drop-down box goes away.


KeyPress Event
==============                        

Occurs when the user presses an ANSI key.

Syntax

Private Sub object_KeyPress( ByVal KeyANSI As MSForms.ReturnInteger)

The KeyPress event syntax has these parts:

Part Description 
object Required. A valid object. 
KeyANSI Required. An integer value that represents a standard numeric ANSI key code. 


Remarks

The KeyPress event occurs when the user presses a key that produces a typeable character (an ANSI key) on a running form while the form or a control on it has the focus. The event can occur either before or after the key is released. This event also occurs if you send an ANSI keystroke to a form or control using either the SendKeys action in a macro or the SendKeys Statement in Visual Basic.

A KeyPress event can occur when any of the following keys are pressed: 

Any printable keyboard character.


CTRL combined with a character from the standard alphabet.


CTRL combined with any special character.


BACKSPACE.


ESC. 
A KeyPress event does not occur under the following conditions: 

Pressing TAB.


Pressing ENTER.


Pressing an arrow key.


When a keystroke causes the focus to move from one control to another. 
Note BACKSPACE is part of the ANSI character set, but DELETE is not. Deleting a character in a control using BACKSPACE causes a KeyPress event; deleting a character using DELETE doesn't.

When a user holds down a key that produces an ANSI keycode, the KeyDown and KeyPress events alternate repeatedly. When the user releases the key, the KeyUp event occurs. The form or control with the focus receives all keystrokes. A form can have the focus only if it has no controls, or if all its visible controls are disabled.

The default action for the KeyPress event is to process the event code that corresponds to the key that was pressed. KeyANSI indicates the ANSI character that corresponds to the pressed key or key combination. The KeyPress event interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

To respond to the physical state of the keyboard, or to handle keystrokes not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL), use the KeyDown and KeyUp event procedures.

The sequence of keyboard-related events is: 

KeyDown


KeyPress


KeyUp 


DblClick Event
================                        

Occurs when the user points to an object and then clicks a mouse button twice.

Syntax

For MultiPage, TabStrip 
Private Sub object_DblClick( index As Long, ByVal Cancel As MSForms.ReturnBoolean)

For other controls
Private Sub object_DblClick( ByVal Cancel As MSForms.ReturnBoolean)

The DblClick event syntax has these parts:

Part Description 
object Required. A valid object. 
index Required. The position of a Page or Tab object within a Pages or Tabs collection. 
Cancel Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event. 


Remarks

For this event to occur, the two clicks must occur within the time span specified by the system's double-click speed setting.

For controls that support Click, the following sequence of events leads to the DblClick event: 

MouseDown


MouseUp


Click


DblClick 
If a control, such as TextBox, does not support Click, Click is omitted fom the order of events leading to the DblClick event.

If the return value of Cancel is True when the user clicks twice, the control ignores the second click. This is useful if the second click reverses the effect of the first, such as double-clicking a toggle button. The Cancel argument allows your form to ignore the second click, so that either clicking or double-clicking the button has the same effect.


MouseDown, MouseUp Events
==========================                        

Occur when the user clicks a mouse button. MouseDown occurs when the user presses the mouse button; MouseUp occurs when the user releases the mouse button.

Syntax

For MultiPage, TabStrip
Private Sub object_MouseDown( index As Long, ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

Private Sub object_MouseUp( index As Long, ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

For other controls
Private Sub object_MouseDown( ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

Private Sub object_MouseUp( ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

The MouseDown and MouseUp event syntaxes have these parts:

Part Description 
object Required. A valid object. 
index Required. The index of the page or tab in a MultiPage or TabStrip with the specified event. 
Button Required. An integer value that identifies which mouse button caused the event. 
Shift Required. The state of SHIFT, CTRL, and ALT.  
X, Y Required. The horizontal or vertical position, in points, from the left or top edge of the form, Frame, or Page. 


Settings

The settings for Button are:

Constant Value Description 
fmButtonLeft 1 The left button was pressed. 
fmButtonRight 2 The right button was pressed. 
fmButtonMiddle 4 The middle button was pressed. 


The settings for Shift are:

Value Description 
1 SHIFT was pressed. 
2 CTRL was pressed. 
3 SHIFT and CTRL were pressed. 
4 ALT was pressed. 
5 ALT and SHIFT were pressed. 
6 ALT and CTRL were pressed. 
7 ALT, SHIFT, and CTRL were pressed. 


You can identify individual keyboard modifiers by using the following constants:

Constant Value Description 
fmShiftMask 1 Mask to detect SHIFT. 
fmCtrlMask 2 Mask to detect CTRL. 
fmAltMask 4 Mask to detect ALT. 


Remarks

For a MultiPage, the MouseDown event occurs when the user presses a mouse button over the control.

For a TabStrip, the index argument identifies the tab where the user clicked. An index of 1 indicates the user did not click a tab. For example, if there are no tabs in the upper right corner of the control, clicking in the upper right corner sets the index to 1.

For a form, the user can generate MouseDown and MouseUp events by pressing and releasing a mouse button in a blank area, record selector, or scroll bar on the form.

The sequence of mouse-related events is: 

MouseDown


MouseUp


Click


DblClick


MouseUp 
MouseDown or MouseUp event procedures specify actions that occur when a mouse button is pressed or released. MouseDown and MouseUp events enable you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keyboard modifiers.

If a mouse button is pressed while the pointer is over a form or control, that object "captures" the mouse and receives all mouse events up to and including the last MouseUp event. This implies that the X, Y mouse-pointer coordinates returned by a mouse event may not always be within the boundaries of the object that receives them.

If mouse buttons are pressed in succession, the object that captures the mouse receives all successive mouse events until all buttons are released.

Use the Shift argument to identify the state of SHIFT, CTRL, and ALT when the MouseDown or MouseUp event occurred. For example, if both CTRL and ALT are pressed, the value of Shift is 6.


MouseMove Event
===============                        

Occurs when the user moves the mouse.

Syntax

For MultiPage, TabStrip 
Private Sub object_MouseMove( index As Long, ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

For other controls
Private Sub object_MouseMove( ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)

The MouseMove event syntax has these parts:

Part Description 
object Required. A valid object name. 
index Required. The index of the page or tab in a MultiPage or TabStrip associated with this event. 
Button Required. An integer value that identifies the state of the mouse buttons. 
Shift Required. Specifies the state of SHIFT, CTRL, and ALT. 
X, Y Required. The horizontal or vertical position, measured in points, from the left or top edge of the control. 


Settings

The index argument specifies which page or tab was clicked over. A 1 designates that the user did not click on any of the pages or tabs.

The settings for Button are:

Value Description 
0 No button is pressed. 
1 The left button is pressed. 
2 The right button is pressed. 
3 The right and left buttons are pressed. 
4 The middle button is pressed. 
5 The middle and left buttons are pressed. 
6 The middle and right buttons are pressed. 
7 All three buttons are pressed. 


The settings for Shift are:

Value Description 
1 SHIFT was pressed. 
2 CTRL was pressed. 
3 SHIFT and CTRL were pressed. 
4 ALT was pressed. 
5 ALT and SHIFT were pressed. 
6 ALT and CTRL were pressed. 
7 ALT, SHIFT, and CTRL were pressed. 


You can identify individual keyboard modifiers by using the following constants:

Constant Value Description 
fmShiftMask 1 Mask to detect SHIFT. 
fmCtrlMask 2 Mask to detect CTRL. 
fmAltMask 4 Mask to detect ALT. 


Remarks

The MouseMove event applies to forms, controls on a form, and labels.

MouseMove events are generated continually as the mouse pointer moves across objects. Unless another object has captured the mouse, an object recognizes a MouseMove event whenever the mouse position is within its borders.

Moving a form can also generate a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can continually generate (cascade) MouseMove events.

If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event might not occur for that space. In such cases, you might need to respond to the MouseMove event in both controls.

You can use the value returned in the Button argument to identify the state of the mouse buttons.

Use the Shift argument to identify the state of SHIFT, CTRL, and ALT when the MouseMove event occurred. For example, if both CTRL and ALT are pressed, the value of Shift is 6.

Note You can use MouseDown and MouseUp event procedures to respond to events caused by pressing and releasing mouse buttons.



SpinDown, SpinUp Events
========================                        

SpinDown occurs when the user clicks the lower or left spin-button arrow. SpinUp occurs when the user clicks the upper or right spin-button arrow.

Syntax

Private Sub object_SpinDown( )

Private Sub object_SpinUp( )

The SpinDown and SpinUp event syntaxes have these parts:

Part Description 
object Required. A valid object. 


Remarks

The SpinDown event decreases the Value property. The SpinUp event increases Value.

Scroll Event
============                        

Occurs when the scroll box is repositioned.

Syntax

For ScrollBar
Private Sub object_Scroll( )

For MultiPage
Private Sub object_Scroll( index As Long, ActionX As fmScrollAction, ActionY As fmScrollAction, ByVal RequestDx As Single, ByVal RequestDy As Single, ByVal ActualDx As MSForms.ReturnSingle, ByVal ActualDy As MSForms.ReturnSingle)

For Frame
Private Sub object_Scroll( ActionX As fmScrollAction, ActionY As fmScrollAction, ByVal RequestDx As Single, ByVal RequestDy As Single, ByVal ActualDx As MSForms.ReturnSingle, ByVal ActualDy As MSForms.ReturnSingle)

The Scroll event syntax has these parts:

Part Description 
object Required. A valid object name. 
index Required. The index of the page in a MultiPage associated with this event. 
ActionX Required. The action that occurred in the horizontal direction. 
ActionY Required. The action that occurred in the vertical direction. 
RequestDx Required. The distance, in points, you want the scroll bar to move in the horizontal direction. 
RequestDy Required. The distance, in points, you want the scroll bar to move in the vertical direction. 
ActualDx Required. The distance, in points, the scroll bar travelled in the horizontal direction. 
ActualDy Required. The distance, in points, the scroll bar travelled in the vertical direction. 


Settings

The settings for ActionX and ActionY are:

Constant Value Description 
fmScrollActionNoChange 0 No change occurred. 
fmScrollActionLineUp 1 A small distance up on a vertical scroll bar; a small distance to the left on a horizontal scroll bar. Movement is equivalent to pressing the up or left arrow keys on the keyboard to move the scroll bar. 
fmScrollActionLineDown 2 A small distance down on a vertical scroll bar; a small distance to the right on a horizontal scroll bar. Movement is equivalent to pressing the down or right arrow keys on the keyboard to move the scroll bar. 
fmScrollActionPageUp 3 One page up on a vertical scroll bar; one page to the left on a horizontal scroll bar. Movement is equivalent to pressing PAGE UP on the keyboard to move the scroll bar. 
fmScrollActionPageDown 4 One page down on a vertical scroll bar; one page to the right on a horizontal scroll bar. Movement is equivalent to pressing PAGE DOWN on the keyboard to move the scroll bar. 
fmScrollActionBegin 5 The top of a vertical scroll bar; the left end of a horizontal scroll bar. 
fmScrollActionEnd 6 The bottom of a vertical scroll bar; the right end of a horizontal scroll bar. 
fmScrollActionPropertyChange  8 The value of either the ScrollTop or the ScrollLeft property changed. The direction and amount of movement depend on which property was changed and on the new property value. 
fmScrollActionControlRequest  9 A control asked its container to scroll. The amount of movement depends on the specific control and container involved. 
fmScrollActionFocusRequest  10 The user moved to a different control. The amount of movement depends on the placement of the selected control, and generally has the effect of moving the selected control so it is completely visible to the user. 


Remarks

The Scroll events associated with a form, Frame, or Page return the following arguments: ActionX, ActionY, ActualX, and ActualY. ActionX and ActionY identify the action that occurred. ActualX and ActualY identify the distance that the scroll box traveled.

The default action is to calculate the new position of the scroll box and then scroll to that position.

You can initiate a Scroll event by issuing a Scroll method for a form, Frame, or Page. Users can generate Scroll events by moving the scroll box.

The Scroll event associated with the stand-alone ScrollBar indicates that the user moved the scroll box in either direction. This event is not initiated when the value of the ScrollBar changes by code or by the user clicking on parts of the ScrollBar other than the scroll box.


Error Event
=============                        

Occurs when a control detects an error and cannot return the error information to a calling program.

Syntax

For MultiPage
Private Sub object_Error( index As Long, ByVal Number As Integer, ByVal Description As MSForms.ReturnString, ByVal SCode As SCode, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, ByVal CancelDisplay As MSForms.ReturnBoolean)

For other controls
Private Sub object_Error( ByVal Number As Integer, ByVal Description As MSForms.ReturnString, ByVal SCode As SCode, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, ByVal CancelDisplay As MSForms.ReturnBoolean)

The Error event syntax has these parts:

Part Description 
object Required. A valid object name. 
index Required. The index of the page in a MultiPage associated with this event. 
Number Required. Specifies a unique value that the control uses to identify the error. 
Description Required. A textual description of the error. 
SCode Required. Specifies the OLE status code for the error. The low-order 16 bits specify a value that is identical to the Number argument. 
Source Required. The string that identifies the control which initiated the event. 
HelpFile Required. Specifies a fully qualified path name for the Help file that describes the error. 
HelpContext Required. Specifies the context ID of the Help file topic that contains a description of the error. 
CancelDisplay Required. Specifies whether to display the error string in a message box. 


Remarks

The code written for the Error event determines how the control responds to the error condition.

The ability to handle error conditions varies from one application to another. The Error event is initiated when an error occurs that the application is not equipped to handle.


BeforeDragOver Event
=====================
                        

Occurs when a drag-and-drop operation is in progress.

Syntax

For Frame
Private Sub object_BeforeDragOver( ByVal Cancel As MSForms.ReturnBoolean, ctrl As Control, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

For MultiPage
Private Sub object_BeforeDragOver( index As Long, ByVal Cancel As MSForms.ReturnBoolean, ctrl As Control, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

For TabStrip
Private Sub object_BeforeDragOver( index As Long, ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

For other controls
Private Sub object_BeforeDragOver( ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState) 

The BeforeDragOver event syntax has these parts:

Part Description 
object Required. A valid object name. 
index Required. The index of the Page in a MultiPage that the drag-and-drop operation will affect. 
Cancel Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event. 
ctrl Required. The control being dragged over. 
Data Required. Data that is dragged in a drag-and-drop operation. The data is packaged in a DataObject. 
X, Y Required. The horizontal and vertical coordinates of the control's position. Both coordinates are measured in points. X is measured from the left edge of the control; Y is measured from the top of the control.. 
DragState Required. Transition state of the data being dragged. 
Effect Required. Operations supported by the drop source. 
Shift Required. Specifies the state of SHIFT, CTRL, and ALT. 


Settings

The settings for DragState are:

Constant Value Description 
fmDragStateEnter 0 Mouse pointer is within range of a target. 
fmDragStateLeave 1 Mouse pointer is outside the range of a target. 
fmDragStateOver 2 Mouse pointer is at a new position, but remains within range of the same target. 


The settings for Effect are:

Constant Value Description 
fmDropEffectNone 0 Does not copy or move the drop source to the drop target. 
fmDropEffectCopy 1 Copies the drop source to the drop target. 
fmDropEffectMove 2 Moves the drop source to the drop target. 
fmDropEffectCopyOrMove  3 Copies or moves the drop source to the drop target. 


The settings for Shift are: 

Constant Value Description 
fmShiftMask 1 SHIFT was pressed. 
fmCtrlMask 2 CTRL was pressed. 
fmAltMask 4 ALT was pressed. 


Remarks

Use this event to monitor the mouse pointer as it enters, leaves, or rests directly over a valid target. When a drag-and-drop operation is in progress, the system initiates this event when the user moves the mouse, or presses or releases the mouse button or buttons. The mouse pointer position determines the target object that receives this event. You can determine the state of the mouse pointer by examining the DragState argument.

When a control handles this event, you can use the Effect argument to identify the drag-and-drop action to perform. When Effect is set to fmDropEffectCopyOrMove, the drop source supports a copy (fmDropEffectCopy), move (fmDropEffectMove), or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectCopy, the drop source supports a copy or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectMove, the drop source supports a move or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectNone. the drop source supports a cancel operation.

Most controls do not support drag-and-drop while Cancel is False, which is the default setting. This means the control rejects attempts to drag or drop anything on the control, and the control does not initiate the BeforeDropOrPaste event. The TextBox and ComboBox controls are exceptions to this; these controls support drag-and-drop operations even when Cancel is False.

KeyDown, KeyUp Events
======================                        

Occur in sequence when a user presses and releases a key. KeyDown occurs when the user presses a key. KeyUp occurs when the user releases a key.

Syntax

Private Sub object_KeyDown( ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As fmShiftState)

Private Sub object_KeyUp( ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As fmShiftState)

The KeyDown and KeyUp event syntaxes have these parts:

Part Description 
object Required. A valid object name. 
KeyCode Required. An integer that represents the key code of the key that was pressed or released. 
Shift Required. The state of SHIFT, CTRL, and ALT. 


Settings

The settings for Shift are:

Constant Value Description 
fmShiftMask 1 SHIFT was pressed. 
fmCtrlMask 2 CTRL was pressed. 
fmAltMask 4 ALT was pressed. 


Remarks

The KeyDown event occurs when the user presses a key on a running form while that form or a control on it has the focus. The KeyDown and KeyPress events alternate repeatedly until the user releases the key, at which time the KeyUp event occurs. The form or control with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

These events also occur if you send a keystroke to a form or control using either the SendKeys action in a macro or the SendKeys Statement in Visual Basic.

The KeyDown and KeyUp events are typically used to recognize or distinguish between: 

Extended character keys, such as function keys.


Navigation keys, such as HOME, END, PAGEUP, PAGEDOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.


Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT).


The numeric keypad and keyboard number keys. 
The KeyDown and KeyUp events do not occur under the following circumstances: 

The user presses enter on a form with a command button whose Default property is set to True.


The user presses esc on a form with a command button whose Cancel property is set to True. 
The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

The sequence of keyboard-related events is: 

KeyDown


KeyPress


KeyUp 
Note The KeyDown and KeyUp events apply only to forms and controls on a form. To interpret ANSI characters or to find out the ANSI character corresponding to the key pressed, use the KeyPress event.



selected dump of event info from various ooo events

key up & key down
=================

dumpEvent: ScriptType VBAInterop
dumpEvent: ScriptCode CommandButton1_KeyDown
dumpEvent: ListenerType com.sun.star.awt.XKeyListener
dumpEvent: Listener methodname com.sun.star.awt.XKeyListener
dumpEvent: arguments;
         [0] (com.sun.star.awt.KeyEvent) { { { Source = (com.sun.star.uno.XInterface) 0x48224bd0 (ImplementationName = "com.sun.star.comp.forms.OButtonControl") }, Modifiers = (short) 0 }, KeyCode = (short) 517, KeyChar = 'f', KeyFunc = (short) 0 }

dumpEvent: ScriptType VBAInterop
dumpEvent: ScriptCode CommandButton1_KeyUp
dumpEvent: ListenerType com.sun.star.awt.XKeyListener
dumpEvent: Listener methodname com.sun.star.awt.XKeyListener
dumpEvent: arguments;
         [0] (com.sun.star.awt.KeyEvent) { { { Source = (com.sun.star.uno.XInterface) 0x48224bd0 (ImplementationName = "com.sun.star.comp.forms.OButtonControl") }, Modifiers = (short) 0 }, KeyCode = (short) 517, KeyChar = 'f', KeyFunc = (short) 0 }

SpinButton
============

click on up

dumpEvent: ScriptCode SpinButton_Scroll
dumpEvent: ListenerType com.sun.star.awt.XAdjustmentListener
dumpEvent: Listener methodname com.sun.star.awt.XAdjustmentListener
dumpEvent: arguments;
         [0] (com.sun.star.awt.AdjustmentEvent) { { Source = (com.sun.star.uno.XInterface) 0x495c60b0 (ImplementationName = "com.sun.star.comp.toolkit.UnoSpinButtonControl") }, Value = (long) 1, Type = (com.sun.star.awt.AdjustmentType) ADJUST_LINE }

click on down

:dumpEvent: ScriptType VBAInterop
dumpEvent: ScriptCode SpinButton_Scroll
dumpEvent: ListenerType com.sun.star.awt.XAdjustmentListener
dumpEvent: Listener methodname com.sun.star.awt.XAdjustmentListener
dumpEvent: arguments;
         [0] (com.sun.star.awt.AdjustmentEvent) { { Source = (com.sun.star.uno.XInterface) 0x495c60b0 (ImplementationName = "com.sun.star.comp.toolkit.UnoSpinButtonControl") }, Value = (long) 0, Type = (com.sun.star.awt.AdjustmentType) ADJUST_LINE }


so, can't tell if its up or down unless we maintain state

ScrollBar
============

dumpEvent: ScriptType VBAInterop
dumpEvent: ScriptCode Scrollbar_Scroll
dumpEvent: ListenerType com.sun.star.awt.XAdjustmentListener
dumpEvent: Listener methodname com.sun.star.awt.XAdjustmentListener
dumpEvent: arguments;
         [0] (com.sun.star.awt.AdjustmentEvent) { { Source = (com.sun.star.uno.XInterface) 0x495c8ac8 (ImplementationName = "stardiv.Toolkit.UnoScrollBarControl") 

so this is ok for _Scroll event

DropButtonClick event in vba
=============================
Doesn't seem to be any thing to tell when a drop list appears, may need to modify the control :-(


Dbl_Click
==========

dumpEvent: Source (com.sun.star.uno.XInterface) 0x47ff01f8
dumpEvent: ScriptType VBAInterop
dumpEvent: ScriptCode Button_MouseDown
dumpEvent: ListenerType com.sun.star.awt.XMouseListener
dumpEvent: Listener methodname com.sun.star.awt.XMouseListener
dumpEvent: arguments;
         [0] (com.sun.star.awt.MouseEvent) { { { Source = (com.sun.star.uno.XInterface) 0x47fe54b0 (ImplementationName = "com.sun.star.comp.forms.OButtonControl") }, Modifiers = (short) 0 }, Buttons = (short) 1, X = (long) 77, Y = (long) 46, ClickCount = (long) 2, PopupTrigger = false }

ClickCount, probably can use this for Dbl_Click, also maybe better to use same for single click ( instread of actionListener )

MouseMove
=========

dumpEvent: Source (com.sun.star.uno.XInterface) 0x48497bb0
dumpEvent: ScriptType VBAInterop
dumpEvent: ScriptCode Button_MouseMove
dumpEvent: ListenerType com.sun.star.awt.XMouseMotionListener
dumpEvent: Listener methodname com.sun.star.awt.XMouseMotionListener
dumpEvent: arguments;
         [0] (com.sun.star.awt.MouseEvent) { { { Source = (com.sun.star.uno.XInterface) 0x413d0828 (ImplementationName = "com.sun.star.comp.forms.OButtonControl") }, Modifiers = (short) 0 }, Buttons = (short) 0, X = (long) 184, Y = (long) 35, ClickCount = (long) 0, PopupTrigger = false }

X & Y are position from the topleft ( not sure if they are in points though )



Summary
===================

Some intitial support for Form Controls provided in vba/patches

At the moment _Change will happen when the Value property of the control changes, need to investigate further as to whether say changed or actionperformed might give the same result

Spin_Up/Spin_Down ( not possible as far as I know without modifying the control )

_Scroll supported

_KeyPress should be possible to translate this (Done needs testing )

_KeyUp should be possible to translate this (Done needs testing )

_KeyDown should be possible to translate this (Done needs testing )

_MouseMove should be possible to translate this (Done needs testing )

_MouseUp should be possible to translate this (Done needs testing )

_MouseDown should be possible to translate this (Done needs testing )

_Dbl_Click should be possible to emulate this (Done needs testing )

_DropButton ( can't see a way to support this without direct modification of the control )

_Error ( nothing appropriate )

_BeforeDropOrPaste ( unclear whether this is possible, cant see anyting in ooo re. controls for this )

_BeforeDragOver ( may be possible with mouse dragged event )



