delete items from a listbox with <DEL>

Started by Thomas Bock, March 19, 2020, 09:52:04 AM

Previous topic - Next topic

Thomas Bock

I'm looking for a way to support the <DEL> key in listboxes.
Many users want to delete items from a list by pressing <DEL> as they can do it in a mail client and explorer.
Is there a way to do this?

GordDavey

Thomas,

If you are using Nomads, then take a look at the _EOM$ var. It will have, $2E$ for the delete key... (I think it was $2E$ I might be off a bit).
If not using nomads, then there is a string var in the syntax of the LIST_BOX READ which will return the eom value.
Gord Davey <gord.davey@Avexware.com>
President - Avexware Corp.
Tel: +1 (519) 835-4322

Mike King

The easiest way in Nomads (or iNomads) is to add logic to the CTL value -1007 (User Ctls).  That logic can do the delete from the list box.

If there are multiple list boxes that you want to handle, you would be better using a right click menu to provide the delete functionality.  In theory you could read the current Focus using SET_FOCUS READ to determine which list box had focus to indicate where you want the delete to occur, but I personally wouldn't do this.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Thomas Bock

There is no event for <DEL> in the listbox. _EOM$ doesn't report anything though the control is set to 'automatic' :(
I'll work with ctL=_-1007. That looks promising after the first tests.
Thank you both.

David Reynolds

This works for me in my application:
Panel does not have User CTLs defined
ListBox defined with Multiple Selections only (not Automatic, or SOE)

In the PROCESS_LB logic I have:


IF (_EOM$=$2E$) THEN {
LIST_BOX READ MY_LB.CTL,SELECTED$; LET SELECTED$=STP(MNEMONIC SELECTED$)
WHILE POS("~"=SELECTED$) ! I use ~ as my row separator
LET X$=SELECTED$(1,POS("~"=SELECTED$)-1),SELECTED$=SELECTED$(POS("~"=SELECTED$)+1)
READ DATA FROM X$ TO LINE$
! do whatever you gotta do with LINE$
WEND
}
IF (_EOM$=$02$ OR _EOM$=$0D$) THEN {
! whatever you need to do on a double-click/Enter
}

Thomas Bock

As it turns out it is the automatic flag, which consumes $2E$.

Mike King

Generally I suggest you use the CTL value as opposed to checking the EOM value.  While not generally done, its possible someone might want to change the Delete key to some other key which can be done using CTL values.

For example you might want to make CTRL-D a delete (which is done in Outlook), this can be done by DEFCTL $04$=-1007 and would work if you test for the CTL value but not if you test for the keyboard value of $2E$
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com