I’ve now got my popup menus working and I have been using them to add bitmaps to the %gr region, and I can move them around the graphics area.
Suppose I now want to select a bitmap and process some data associated with the item represented by the bitmap.
If I left click on an area without a bitmap, using clearwin_string@(‘callback_reason’) in the %^gr call back will return MOUSE_LEFT_CLICK followed by MOUSE_LEFT_RELEASE. If I left click and release on a bitmap it returns LEFT_MOUSE_PRESS – so I can differentiate between a left click on a free area and on a bitmap. (LEFT_MOUSE_PRESS does not appear in the CW documentation.)
If I click left on a bitmap, followed by a right click to activate the popup menu, the initial left click %gr call back reason MOUSE_LEFT_PRESS can be saved along with the mouse coordinates from GRAPHICS_MOUSE_X and GRAPHICS_MOUSE_Y and passed to the %pm call back. If the %gr call back reason is not MOUSE_LEFT_PRESS, then the %pm returns without doing anything.
Otherwise, as I know the top left coordinates of each bitmap and the size of each bitmap, I could then do a “point in rectangle” test to identify the selected bitmap, and then carry out whatever actions are required.
I suspect (or perhaps I should say hope) that there may be a more direct approach to identify the handle of a bitmap when the user clicks on (but does not move) it, but I’ve failed to find it. Does it exist?
Clearwin_info@(‘DRAGGED_ICON’) is not what I am looking for as the bitmap is not being moved in this case.
Thanks
Ken