TIP: Double Click and Right click in Listbox

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

Locked
User avatar
dpayer
Posts: 1394
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

TIP: Double Click and Right click in Listbox

Post by dpayer »

When using a listbox, at times you want an action based on a double click or a right click. There is a circumstance where it may not work as you expect even though you double click or right click. This happens when the selection was not first clicked normally to high lite it. When you select the item by clicking once normally, you can do the right click or double click as expected.

Here is a work around to have a single action:

Code: Select all

If "[selectedlistboxitem]" "=" ""
clickmouse
Endif
At the top of the section for double click or right click, place the code above (using the correct variable for your listbox).

When you double click, the listbox will check the variable for the selected item. If empty, it will emulate a click and select the item. Then it will enact the code you have for the right click or double click.

You may want to set the variable to be empty when done so it doesn't use a previously selected item even though you click something else.
David Payer
Des Moines, Iowa
USA
Locked