Clicked

The Clicked event has different arguments for different objects:

Object

See

Menus

Syntax 1 For menus

ListView and Toolbar controls

Syntax 2 For ListView controls

Tab controls

Syntax 3 For Tab controls

TreeView controls

Syntax 4 For TreeView controls

Window and progress bar controls

Syntax 5 For windows and progress bars

Other controls

Syntax 6 For other controls

For information about the DataWindow control’s Clicked event, see the DataWindow Reference or the online Help.


Syntax 1 For menus

Description

Occurs when the user chooses an item on a menu.

Event ID

Event ID

Objects

None

Menu

Arguments

None

Returns

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

Example 1

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


Syntax 2 For ListView 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.

Returns

Long. Return code choices (specify in a RETURN statement):

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.

NoteUsing 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

Example 2

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


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)

Returns

Long. Return code choices (specify in a RETURN statement):

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

Example 3

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


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)

Returns

Long. Return code choices (specify in a RETURN statement):

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

Example 4

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


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).

Returns

Long. Return code choices (specify in a RETURN statement):

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

Example 5

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


Syntax 6 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

Returns

Long. Return code choices (specify in a RETURN statement):

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

Example 6

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