KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Getting Listbox Cell of Mouse Cursor Position
PRODUCT: 4D | VERSION: 16R5 | PLATFORM: Mac & Win
Published On: January 5, 2018

In 4D v16R5 the LISTBOX GET CELL POSITION command has been updated to make it easier to obtain the cell of a listbox which a mouse cursor is currently hovering. The command now takes an additional two (2) new optional parameters for the mouse cursors coordiantes:

4D Versions < v16R5:


4D Versions => v16R5:


This update allows ease of providing user interface enhancements to Listboxes by applying color changes (light highlights) or custom help tips based on the individual cells which can be identified with two lines of code using the GET MOUSE command and then passing the resulting coordinates to the LISTBOX GET CELL POSITION command.

Example Code:

C_REAL($mX_r)
C_REAL($mY_r)
C_LONGINT($mBut_l)
C_LONGINT($col_l)
C_LONGINT($row_l)

GET MOUSE($mX_r;$mY_r;$mBut_l)
LISTBOX GET CELL POSITION(*;"LBox";$mX_r;$mY_r;$col_l;$row_l)

//...Additonal Code to work with the cell


Additional Information:
Prior to v16R5 it was possible to get the cell position where the mouse cursor was hovering, but it required more code and calculations. Below are links to two utility methods that did this: