| [ Return to Bugs & Features | Post Text | Post File | SVN ⇄ GIT | Prev | Next ]
STR #3282
Application: | FLTK Library |
Status: | 4 - Pending |
Priority: | 2 - Low, e.g. a documentation error or undocumented side-effect |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Core Library |
Summary: | Fl_Table::handle() returns 1 on right clicks |
Version: | 1.4-current |
Created By: | mikesart |
Assigned To: | greg.ercolano |
Fix Version: | Unassigned |
Update Notification: | |
Trouble Report Files:
[ Post File ]
Trouble Report Comments:
[ Post Text ]
|
#1 | mikesart 17:29 Jan 28, 2016 |
| This bit of code in Fl_Table.cxx is returning 1 when right clicking on my table, which is preventing my poor popup menu from showing up.
switch ( context ) { case CONTEXT_CELL: // FL_PUSH on a cell? ret = 1; // express interest in FL_RELEASE break;
I believe it should check for ( _event_button == 1 ) like the CONTEXT_NONE and CONTEXT_COL_HEADER cases. | |
|
#2 | matt 07:37 Feb 02, 2019 |
| Assigned to Greg. Not sure if this request breaks things. It feels to me like setting a callback may also be used to pop up menus per item?! | |
|
#3 | greg.ercolano 23:55 Dec 15, 2023 |
| Yeah, not sure I can make the requested change.
If you want a popup menu, the way to do it is as matt describes, basically in the table's callback(): ____________________________________________________________________ if ( Fl::event_button() == FL_RIGHT_MOUSE ) { // Right mouse click? int context = callback_context(); // get the table's callback context switch (context) { // EXAMPLE: clicked on header or cell? popup a menu case CONTEXT_COL_HEADER: case CONTEXT_CELL: { // Create context sensitive menu label char s[80]; if ( context == CONTEXT_CELL ) sprintf(s, "Cell %c%d", 'A'+callback_col(), callback_row()); else sprintf(s, "Column %c", 'A'+callback_col()); // Create context menu dynamically, get user's choice Fl_Menu_Button menu(Fl::event_x(), Fl::event_y(), 80, 1); menu.add(s, 0, 0, 0, FL_MENU_DIVIDER|FL_MENU_INACTIVE); menu.add("Item 1", 0, 0); menu.add("Item 2", 0, 0); // Post the menu, see what the user picked const Fl_Menu_Item *item = menu.popup(); if ( item ) printf("You chose '%s'\n", item->label()); break; } default: break; } } ____________________________________________________________________
Attaching a fully working example table example program, "table-with-right-click-menu.cxx", which has a right-click context sensitive menu that posts (for example) over:
- Column headers - Cells
The posted menu shows the column and row# as the menu title, showing how the menu knows which cell it was posted over, so the menu can be appropriate for that particular cell.
Will probably close this after a few days, unless the OP comes back with a problem not solved by this approach. | |
|
#4 | greg.ercolano 00:11 Dec 16, 2023 |
| Added examples/table-with-right-click-menu.cxx to 1.4.x with commit bdbd349. | |
|
#5 | greg.ercolano 08:51 Dec 29, 2023 |
| Hmm, was about to close, but gonna leave this open a bit more to see if there's some way through the API to provide a solution.
Fl_Menu_Button provides a button mask via type(), e.g.
Fl_Menu_Button mb(...); ... mb.type(POPUP1); // popup menu when left button (POPUP1) is clicked ...
There's probably a better API than using type(), but I'm thinking Fl_Table could make use of such a mask so as to only invoke the callback() when the proper mask bits are set.
Also, I imagine we might need such a mask for handing different modern input devices, such as pen tablets (eraser clicks and option button clicks) and touch screens (multi-finger gestures).
The default for such a mask could preserve existing behavior, while allowing new applications to only respond to certain clicks (e.g. only left-clicks)
Other devs: are there any plans or suggest ways the application can specify which buttons widgets respond to when invoking callbacks?
For example, currently left/middle/right will "click" an Fl_Button, but perhaps we'd want to allow the user to control this in a way that affects other widgets too (such as Fl_Table cells). | |
|
#6 | greg.ercolano 08:51 Dec 29, 2023 |
| Oops, closed by accident - leaving open/pending. | |
|
#7 | greg.ercolano 09:08 Dec 29, 2023 |
| Posted on fltk.dev today to see if there's any plans for the above mentioned API changes.
Subject for that thread is:
RFC: api for application to control which mouse buttons trigger callbacks?
Will follow up here to see if that's an option to solve. | |
[ Return to Bugs & Features | Post Text | Post File ]
|
| |