KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Editing list box cells with a single click
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: June 29, 2010

In a list box based on a selection users can edit data inline by slowly clicking twice on a cell. One click to highlight the contents, and a second to make the cell enterable. You can avoid the requirment for two clicks by adding the following code to the list box object method:

Case of
  :(Form event = On Clicked)

   C_POINTER(calVar_p)
   C_LONGINT(col; row)

   `ListBox is the Object Name for the list box object

   LISTBOX GET CELL POSITION(*;"ListBox";col;row;colVar_p)
   EDIT ITEM(colVar_p->;row)
End case


The On Clicked object property needs to be checked in the List Box's object property list in the Event theme.

Commented by Trieu La on November 3, 2010 at 7:16 AM
Doing this if listbox is set for single line item highlight this is fine, but the above breaks multiple select option; you trap (read greedy) legitimate multiple selection functionality.

Combine the On Clicked event with Shift Down and/or Windows Ctrl Down to allow users to select multiple items in a list, but on single click (no key modifiers) enter a cell on one click.

Abbreviated Example:

Case of
: (Form event=On Clicked )
  ` make sure we aren't trying to highlight stuff
If (Not(Shift down | Windows Ctrl down))
LISTBOX GET CELL POSITION(*;"ListBox";col;row;colVar_p)
EDIT ITEM(colVar_p->;row)
End if
End case

-James Rowe