PxPlus User Forum

Twitter Twitter Twitter

Author Topic: delete items from a listbox with <DEL>  (Read 167 times)

Thomas Bock

  • Diamond Member
  • *****
  • Posts: 110
    • View Profile
delete items from a listbox with <DEL>
« 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?

GordDavey

  • Member
  • **
  • Posts: 5
    • View Profile
Re: delete items from a listbox with <DEL>
« Reply #1 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.
Gord Davey <gord.davey@daveycomputing.com>
President - Gord Davey Computing
Tel: +1 (519) 835-4322

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3267
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: delete items from a listbox with <DEL>
« Reply #2 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.

Thomas Bock

  • Diamond Member
  • *****
  • Posts: 110
    • View Profile
Re: delete items from a listbox with <DEL>
« Reply #3 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.

David Reynolds

  • Member
  • **
  • Posts: 12
    • View Profile
Re: delete items from a listbox with <DEL>
« Reply #4 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
}

Thomas Bock

  • Diamond Member
  • *****
  • Posts: 110
    • View Profile
Re: delete items from a listbox with <DEL>
« Reply #5 on: March 20, 2020, 02:41:42 AM »
As it turns out it is the automatic flag, which consumes $2E$.

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3267
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: delete items from a listbox with <DEL>
« Reply #6 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$