4D Blog

Home Product List boxes: Manage clicks in edited cells

List boxes: Manage clicks in edited cells

January 22, 2021

Product

As a developer, you’re used to handling events inside form objects. The most common is the on clicked form event which can be used in most objects, including list boxes. In this particular object, clicks can be managed either at the list box level itself or within the column methods.

And starting with 4D v18 R6, the on clicked form event is triggered whether a cell is being edited or not, giving you increased control and improving the interface.

Here is a very simple example:

You want to display possible values using a contextual menu for a cell when it’s being edited. However, when the row is simply selected, you want to offer a color choice for that particular row or cell.

It’s very simple to do this!

During the on clicked event, just check if the cell is being edited or not. Then depending on the result, display one menu or another!

If (Contextual click)  // you don't want to do anything if the click is not a contextual click
  If (Is editing text)  // if the text is being edited, suggest input values
    $dynMenu:=Create menu
    APPEND MENU ITEM($dynMenu; "Alpha")
    SET MENU ITEM PARAMETER($dynMenu; -1; "Alpha")
    APPEND MENU ITEM($dynMenu; "Bravo")
    SET MENU ITEM PARAMETER($dynMenu; -1; "Bravo")
    APPEND MENU ITEM($dynMenu; "Charlie")
    SET MENU ITEM PARAMETER($dynMenu; -1; "Charlie")
    $choice:=Dynamic pop up menu($dynMenu)
    If ($choice#"")
      // use the .row info present in the Form event object
      T1{FORM Event.row}:=$choice 
    End if 
  Else   // if the text is NOT being edited, suggest color for the text
    $dynMenu:=Create menu
    APPEND MENU ITEM($dynMenu; "Blue")
    SET MENU ITEM PARAMETER($dynMenu; -1; "Blue")
    APPEND MENU ITEM($dynMenu; "Green")
    SET MENU ITEM PARAMETER($dynMenu; -1; "Green")
    $choice:=Dynamic pop up menu($dynMenu)
    If ($choice#"")
       // use columnName and row attributes of the Form event object
      LISTBOX SET ROW COLOR(*; FORM Event.columnName; FORM Event.row; $choice)  
    End if 
  End if 
  RELEASE MENU($dynMenu)
End if

Find more details about form events in the doc center!

Compatibility note

If you already have code that runs during the on clicked event, you may want to stop the execution of that code when a click occurs inside an edited cell. In this case, simply test the state of this cell with the is editing text function in advance.

Check out the documentation for more technical details and join us on the 4D forum for any questions!

Discuss

Tags Listbox, v18 R6, v19

Latest related posts

  • October 23, 2025

    Starting Qodly studio is just two clicks away

  • October 22, 2025

    Localize your Qodly Pages: A Practical Guide

  • October 21, 2025

    New Way to Control Your HTTP Responses

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert • After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • AI
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy