Skip to content
webweenie edited this page Oct 10, 2022 · 16 revisions

twinBASIC Events

Event procedures are special subroutines that objects call automatically when a pre-defined action occurs.


Activate, Deactivate Events

Inputs

None

Outputs

None

The Activate event is raised when an object becomes the active window. The Initialize event occurs first, when the object is initialized. The Load event occurs next and is often used to initialize any subcomponents or controls. The Activate event occurs after the Load event, and then each time the object becomes the active window.

Deactivate occurs each time an object becomes a non-active window.

Change

Inputs

None

Outputs

None

The Change event is raised when the data in a control is changed

ComboBox

The Change event for a ComboBox is raised when the data in the textbox area of the combo box is edited.

Note: The Change event is not raised when an item is selected using a mouse or the keyboard. To detect a change in which item is selected use the Click event.

Click

Inputs

None

Outputs

None

The Click event is raised when the object is clicked with the primary mouse button and the mouse button is released while the mouse pointer is still over the object. In some instances, for example with the Command Button, the click event will also be raised when the object has focus and the Enter key or Spacebar is pressed. Note: If there is an event handler for the Click event with code in it, the DblClick event will not be raised.

Event Order

The event order for the ListBox and CommandButton is MouseDown, Click, then MouseUp (Down-Click-Up). The event order for the FileListBox, Label, and PictureBox is MouseDown, MouseUp, and Click (Down-Up-Click).

ComboBox

The click event is also raised if the object has focus a list item is selected using the arrow keys.

CommandButton

The click event is also raised if the object has focus and the Enter key or SpaceBar is pressed.

CheckBox

The click event is also raised when the CheckBox has focus and the SpaceBar is pressed.

Frame

The click event is only raised when the primary mouse button clicks on the frame object. If any controls inside the frame are clicked, the clicked control will receive the event and the click event for the frame will not be called.

ListBox

The click event is also raised if the object has focus a list item is selected using the arrow keys.

OptionButton

The click event is also raised when the arrow keys are used to select an Option Button within a group.

PictureBox

The click event is raised by a mouse click of either mouse button on the object. If the object has focus, the SpaceBar and arrow keys will also cause the click event to be raised.

TextBox

The click event is also raised when the object is clicked with the secondary mouse button. However, depending on the operating system, a context menu may display first and the click event is raised when the context menu is dismissed, or one of the context menu items is selected.

DblClick

Inputs

None

Outputs

None

the DblClick event is raised when the primary mouse button is pressed quickly over an object twice.

Form

The DblClick event occurs when the user double-clicks an empty area of a form or on a disabled control.

ComboBox

Double-clicks on a ComboBox only raise the DblClick event if the ComboBox Style is set to vbComboSimple.

DragDrop

Inputs

  • Source As Control - the control that was dropped
  • X As Single - the X coordinate position of the mouse when the mouse button was released
  • Y As Single - the Y coordinate position of the mouse when the mouse button was released

Outputs

None

The DragDrop event is raised when a control is dragged over an object and the mouse button released. It will also be raised if the Drag method is used with its action argument set to 2 (Drop)

DragOver

Inputs

  • Source As Control - the control that was dropped
  • X As Single - the X coordinate position of the mouse when the mouse button was released
  • Y As Single - the Y coordinate position of the mouse when the mouse button was released
  • State As Integer TransitionState - the state of the move, Enter, Leave, or Over.

Outputs

None

The DragOver Event method is raised when the user drags a control on top of the control with the DragOver event.

DropDown

Inputs

None

Outputs

None

The DropDown Event method...

GotFocus

Inputs

None

Outputs

None

The GotFocus event is raised when the object receives the focus. The object can get focus when it is clicked with the mouse, or by the user tabbing into the object. When an object has focus, it will receive input from the keyboard. Use the TabOrder and TabIndex properties to determine if and when a control receives focus via the keyboard.

Note: a control can only receive focus if it is visible and enabled.

Hide Event (UserControl Object)

Inputs

Outputs

The Hide Event (UserControl Object) method...

Initialize

Inputs

None

Outputs

None

The initialize event is raised when the object is initialized during the form load. This event is useful to populate the object with data or otherwise prepare it for the user.

KeyDown, KeyUp Events

Inputs

  • KeyCode: Integer - the ASCII value of the key pressed.
  • Shift: KeyMask - the bitwise value representing all of the shifting keys pressed.

Outputs

None

The KeyDown event is the first of the key events to be raised and occurs when the key is pressed down. The KeyDown event passes in the KeyCode and the Shift state. The KeyCode represents the ASCII value of the key that was pressed. The Shift parameter represents which of the three "shift" keys were also pressed. The possible values of Shift are: 1 = Shift Key, 2 = CTRL key, and 4 = ALT key. Bitwise logic can be used to determine if more than one key was being pressed. The code below can be used to determine which shifting keys are pressed:

    Private Sub Object1_KeyDown(KeyCode As Integer, Shift As Integer) Handles Object1.KeyDown
        Dim bShift As Boolean = vbShiftMask And Shift > 0
        Dim bAlt As Boolean = vbAltMask And Shift > 0
        Dim bCtrl As Boolean = vbCtrlMask And Shift > 0
        
	'Add logic here that uses the boolean values to suit your needs.
    End Sub

Note: the KeyCode represents the key pressed, not the ASCII value for the character. Because of this, a lower-case and upper-case letter will have the same KeyCode value. Use the Shift value to determine if the shift key was down, if necessary. The KeyUp event is the final key event to be raised and occurs when the user releases the key. The KeyUp event has the same inputs as the KeyDown. If a form's KeyPreview property is set to TRUE, the form will receive the Key events before the control does.

KeyPress

Inputs

  • KeyASCII: Integer - the ASCII value of the key pressed.

Outputs

The KeyPress event is similar to the KeyDown, but it happens after the KeyDown event and it passes in the ASCII value of the key pressed via the KeyASCII property. Unlike the KeyDown and KeyUp events, the ASCII value passed into the KeyPress event will be case sensitive. Setting this property to 0 (zero) within the keypress event will nullify the keypress and, effectively, ignore it.

Load

Inputs

Outputs

The Load Event method...

LostFocus

Inputs

None

Outputs

None

The LostFocus event is raised when the object loses focus. An object can lose focus when the user clicks the mouse on something else or uses the tab key to move the input selector.

MouseDown, MouseUp Events

Inputs

  • Button: Button - the ASCII value of the key pressed.
  • Shift: KeyMask - the bitwise value representing all of the shifting keys pressed.
  • X: Integer - the number of pixels the mouse is from the left edge of the object's container
  • Y: Integer - the number of pixels the mouse is from the top edge of the object's container

Outputs

None

The MouseDown event is raised when the mouse button is pressed while over the object. The MouseUp event is raised when the mouse button is released.

MouseMove

Input Parameters

  • Button: Button - the ASCII value of the key pressed.
  • Shift: KeyMask - the bitwise value representing all of the shifting keys pressed.
  • X: Integer - the number of pixels the mouse is from the left edge of the object's container
  • Y: Integer - the number of pixels the mouse is from the top edge of the object's container

The MouseMove event is raised when the mouse is moved over the object. The MouseMove event has several parameters that provide useful information to the event. The Button parameter is an integer value that represents which button was pressed. The possible values are 1 = Left button, 2 = Right button, and 4 = Center button. See the KeyDown event for information on using bitwise boolean logic to determine which buttons were pressed. The Shift parameter works the same way for the MouseMove as it does for the KeyPress. The X and Y parameters provide the location of the mouse as it moves.

OLECompleteDrag

Inputs

Outputs

The OLE Event...

OLEDragDrop

Inputs

Outputs

The OLE Event...

OLEDragOver

Inputs

Outputs

The OLE Event...

OLEGiveFeedback

Inputs

Outputs

The OLE Event...

OLESetData

Inputs

Outputs

The OLE Event...

OLEStartDrag

Inputs

Outputs

The OLE Event...

Paint

Inputs

Outputs

The Paint Event method...

Resize

Inputs

Outputs

The Resize Event method...

Scroll

Inputs

None

Outputs

None

The Scroll event is raised when the user scrolls the list or area within the control.

Timer

Inputs

Outputs

The Timer Event method...

Clone this wiki locally