STR #3282

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]

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
Created By:mikesart
Assigned To:greg.ercolano
Fix Version:Unassigned
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

Post File ]
Name/Time/Date Filename/Size top right image
#1 greg.ercolano
23:55 Dec 15, 2023
bottom left image   bottom right image

Trouble Report Comments:

Post Text ]
Name/Time/Date Text top right image
#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

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_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());
      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 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.
bottom left image   bottom right image

Return to Bugs & Features | Post Text | Post File ]


Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to ''.