PxPlus User Forum

Main Board => Discussions => Nomads => Topic started by: Thomas Bock on March 19, 2020, 09:52:04 AM

Title: delete items from a listbox with <DEL>
Post by: Thomas Bock on March 19, 2020, 09:52:04 AM
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?
Title: Re: delete items from a listbox with <DEL>
Post by: GordDavey on March 19, 2020, 10:06:25 AM
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.
Title: Re: delete items from a listbox with <DEL>
Post by: Mike King on March 19, 2020, 10:17:03 AM
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.
Title: Re: delete items from a listbox with <DEL>
Post by: Thomas Bock on March 19, 2020, 10:29:39 AM
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.
Title: Re: delete items from a listbox with <DEL>
Post by: David Reynolds on March 19, 2020, 01:15:08 PM
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:

Code: [Select]
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
}
Title: Re: delete items from a listbox with <DEL>
Post by: Thomas Bock on March 20, 2020, 02:41:42 AM
As it turns out it is the automatic flag, which consumes $2E$.
Title: Re: delete items from a listbox with <DEL>
Post by: Mike King on March 22, 2020, 02:28:09 PM
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$