Clicked

The Clicked event has different arguments for different objects:

Object

See

Menus

Syntax 1

ListView and Toolbar controls

Syntax 2

Tab controls

Syntax 3

TreeView controls

Syntax 4

Window and progress bar controls

Syntax 5

Ribbon controls

Syntax 6

Other controls

Syntax 7


For information about the DataWindow control's Clicked event, see the section called “Clicked” in DataWindow Reference.

Syntax 1: For menus

Description

Occurs when the user chooses an item on a menu.

Event ID

Event ID

Objects

None

Menu


Arguments

None

Return Values

None (do not use a RETURN statement)

Usage

If the user highlights the menu item without choosing it, its Selected event occurs.

If the user chooses a menu item that has a cascaded menu associated with it, the Clicked event occurs, and the cascaded menu is displayed.

Examples

This script is for the Clicked event of the New menu item for the frame window. The wf_newsheet function is a window function. The window w_genapp_frame is part of the application template you can generate when you create a new application:

/* Create a new sheet */
w_genapp_frame.wf_newsheet( )

See also

Selected

Syntax 2: For ListView and Toolbar controls

Description

Occurs when the user clicks within the ListView control, either on an item or in the blank space around items.

Event ID

Event ID

Objects

pbm_lvnclicked

ListView


Arguments

Argument

Description

index

Integer by value (the index of the ListView item the user clicked). The value of index is -1 if the user clicks within the control but not on a specific item.


Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Usage

The Clicked event occurs when the user presses the mouse button. The Clicked event can occur during a double-click, in addition to the DoubleClicked event.

In addition to the Clicked event, ItemChanging and ItemChanged events can occur when the user clicks on an item that does not already have focus. BeginLabelEdit can occur when the user clicks on a label of an item that has focus.

Using the ItemActivate event for ListView controls

You can use the ItemActivate event (with the OneClickActivate property set to true) instead of the Clicked event for ListView controls.

Examples

This code changes the label of the item the user clicks to uppercase:

IF index = -1 THEN RETURN 0
 
This.GetItem(index, llvi_current)
llvi_current.Label = Upper(llvi_current.Label)
This.SetItem(index, llvi_current)
RETURN 0

See also

ColumnClick

DoubleClicked

ItemActivate

ItemChanged

ItemChanging

RightClicked

RightDoubleClicked

Syntax 3: For Tab controls

Description

Occurs when the user clicks on the tab portion of a Tab control.

Event ID

Event ID

Objects

pbm_tcnclicked

Tab


Arguments

Argument

Description

index

Integer by value (the index of the tab page the user clicked)


Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Usage

The Clicked event occurs when the mouse button is released.

When the user clicks in the display area of the Tab control, the tab page user object (not the Tab control) gets a Clicked event.

The Clicked event can occur during a double-click, in addition to the DoubleClicked event.

In addition to the Clicked event, the SelectionChanging and SelectionChanged events can occur when the user clicks on a tab page label. If the user presses an arrow key to change tab pages, the Key event occurs instead of Clicked before SelectionChanging and SelectionChanged.

Examples

This code makes the tab label bold for the fourth tab page only:

IF index = 4 THEN 
   This.BoldSelectedText = TRUE
ELSE
   This.BoldSelectedText = FALSE
END IF

See also

DoubleClicked

RightClicked

RightDoubleClicked

SelectionChanged

SelectionChanging

Syntax 4: For TreeView controls

Description

Occurs when the user clicks an item in a TreeView control.

Event ID

Event ID

Objects

pbm_tvnclicked

TreeView


Arguments

Argument

Description

handle

Long by value (the handle of the TreeView item the user clicked)


Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Usage

The Clicked event occurs when the user presses the mouse button.

The Clicked event can occur during a double-click, in addition to the DoubleClicked event.

In addition to the Clicked event, GetFocus occurs if the control does not already have focus.

Examples

This code in the Clicked event changes the label of the item the user clicked to uppercase:

TreeViewItem ltvi_current
 
This.GetItem(handle, ltvi_current)
ltvi_current.Label = Upper(ltvi_current.Label)
This.SetItem(handle, ltvi_current)

See also

DoubleClicked

RightClicked

RightDoubleClicked

SelectionChanged

SelectionChanging

Syntax 5: For windows and progress bars

Description

Occurs when the user clicks in an unoccupied area of the window or progress bar (any area with no visible, enabled object).

Event ID

Event ID

Objects

pbm_lbuttonclk

Window

pbm_lbuttondwn

HProgressBar, VProgressBar


Arguments

Argument

Description

flags

UnsignedLong by value (the modifier keys and mouse buttons that are pressed).

Values are:

  • 1 -- Left mouse button

  • 2 -- Right mouse button (windows only)

  • 4 -- Shift key

  • 8 -- Ctrl key

  • 16 -- Middle mouse button (windows only)

In the Clicked event for windows, the left mouse button is being released, so 1 is not summed in the value of flags.

For an explanation of flags, see Syntax 2 of MouseMove.

xpos

Integer by value (the distance of the pointer from the left edge of the window workspace or control in pixels).

ypos

Integer by value (the distance of the pointer from the top of the window's workspace or control in pixels).


Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Usage

The Clicked event occurs when the user presses the mouse button down in progress bars and when the user releases the mouse button in windows.

If the user clicks on a control or menu in a window, that object (rather than the window) gets a Clicked event. No Clicked event occurs when the user clicks the window's title bar.

When the user clicks on a window, the window's MouseDown and MouseUp events also occur.

When the user clicks on a visible disabled control or an invisible enabled control, the window gets a Clicked event.

Examples

If the user clicks in the upper left corner of the window, this code sets focus to the button cb_clear:

IF (xpos <= 600 AND ypos <= 600) THEN
   cb_clear.SetFocus( )
END IF

See also

DoubleClicked

MouseDown

MouseMove

MouseUp

RButtonDown

Syntax 6: For Ribbon controls

Description

This is a user event which occurs when the user clicks on an item within a RibbonBar control.

Make sure the parameter (quantities and types) of the user event is correctly defined according to the requirement of the ribbon control.

Applies to

Ribbon controls (including RibbonTabButtonItem, RibbonLargeButtonItem, RibbonSmallButtonItem, RibbonCheckBoxItem, and RibbonMenuItem)

Arguments for RibbonTabButtonItem, RibbonLargeButtonItem, RibbonSmallButtonItem, RibbonCheckBoxItem

Argument

Description

ItemHandle

Long. The handle of the item.


Arguments for RibbonMenuItem (of Normal(0) type)

Argument

Description

ItemHandle

Long. The handle of the button the menu is associated with.

Index

Long. The index of the menu item clicked.

SubIndex

Long. The index of the submenu item clicked. 0 indicates the event is triggered by the main menu.


Arguments for RibbonMenuItem (of Recent(2) type)

Argument

Description

ItemHandle

Long. The handle of the button the menu is associated with.

Index

Long. The index of the menu item clicked.


Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Examples

This example is a user event for a tab button. In this example, the Ue_TabButtonClicked user event must be defined with a long parameter for receiving the handle of TabButton where the mouse is clicking.

RibbonTabButtonItem lr_TabButton
lr_TabButton.Clicked = "Ue_TabButtonClicked"

//Ue_TabButtonClicked user event must have a long parameter for receiving 
//the handle of TabButton where the mouse is clicking, as below
event type long ue_tabbuttonclicked(long itemhandle);
RibbonTabButtonItem lr_TabButton
rbb_1.GetTabButton(ItemHandle,lr_TabButton)
//...
Return 1
end event

This example is a user event for a menu item in the ribbon menu. In this example, the Ue_MenuClicked user event must be defined with three long parameters for receiving the handle of the tab/large/small button and the index numbers of the menu and sub menu. Each menu item can be bound with different events or the same event.

//Ue_MenuClicked user event must have three long parameters for receiving the 
//handle of Tab/Large/Small Button and the index number of the menu and
//sub menu. Each MenuItem can bind with different events or the same event.

//In the following example, the same event is bound to get RibbonMenu:
event type long ue_menuclicked(long itemhandle, long index, long subindex);
Integer li_Return
RibbonMenu lr_Menu
RibbonMenuItem lr_MenuItem

li_Return = rbb_1.GetMenuByButtonHandle (ItemHandle, lr_Menu)
If li_Return = 1 Then
 If SubIndex = 0 Then
  li_Return = lr_Menu.GetItem (Index, lr_MenuItem)
  //...
 Else
  li_Return = lr_Menu.GetItem (Index, SubIndex, lr_MenuItem)
  //...
 End If
Else
 Return 0
End If

Return 1
end event

This example is a user event for a master menu item in the application menu. In this example, the Ue_MasterMenuClicked user event must be defined with three Long parameters for receiving the handle of the application button and the index numbers of the master menu item and submenu item. Each menu item can be bound with different events or the same event.

//Ue_MasterMenuClicked user event must have three Long parameters for receiving the
//handle of Application Button and the index numbers of the master menu and
//sub menu. Each MenuItem can bind with different events or the same event.

//In the following example, the same event is bound to get RibbonApplicationMenu:
event type long ue_mastermenuclicked(long itemhandle, long index, long subindex);
Integer li_Return
RibbonApplicationMenu lr_Menu
RibbonMenuItem lr_MenuItem

li_Return = rbb_1.GetMenuByButtonHandle(ItemHandle, lr_Menu)
If li_Return = 1 Then
 If SubIndex = 0 Then
  li_Return = lr_Menu.GetMasterItem(Index, lr_MenuItem)
  //...
 Else
  li_Return = lr_Menu.GetMasterItem(Index,SubIndex, lr_MenuItem)
  //...
 End If
Else
 Return 0
End If

Return 1
end event

This example is a user event for the recent menu item in the application menu. In this example, the Ue_RecentMenuClicked user event must be defined with two Long parameters for receiving the handle of the application button and the index number of the recent menu item. Each menu item can be bound with different events or the same event.

//Ue_RecentMenuClicked user event must have two Long parameters for receiving the
//handle of Application Button and the index number of Recent Menu.
//Each MenuItem can bind with different events or the same event.

//In the following example, the same event is bound to get RibbonApplicationMenu.
event type long ue_recentmenuclicked(long itemhandle, long index);
Integer li_Return
RibbonApplicationMenu lr_Menu
RibbonMenuItem lr_MenuItem

li_Return = rbb_1.GetMenuByButtonHandle(ItemHandle,lr_Menu)
If li_Return = 1 Then
 li_Return = lr_Menu.GetRecentItem(Index,lr_MenuItem)
 //...
Else
 Return 0
End If

Return 1
end event

See also

Modified

Selected

SelectionChanged

Syntax 7: For other controls

Description

Occurs when the user clicks on the control.

Event ID

Event ID

Objects

pbm_bnclicked

CheckBox, CommandButton, Graph, OLE, Picture, PictureHyperLink, PictureButton, RadioButton, StaticText, StaticHyperLink

pbm_lbuttondown

DatePicker, MonthCalendar


Arguments

None

Return Values

Long.

Return code choices (specify in a RETURN statement):

0 -- Continue processing

Usage

The Clicked event occurs when the user releases the mouse button.

If another control had focus, then a GetFocus and a Clicked event occur for the control the user clicks.

Examples

This code in an OLE control's Clicked event activates the object in the control:

integer li_success
li_success = This.Activate(InPlace!)

See also

GetFocus

RButtonDown