STR #1263

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 | Roadmap 2.0 | Post Text | Post File | SVN ⇄ GIT ]

STR #1263

Application:FLTK Library
Status:5 - New
Priority:1 - Request for Enhancement, e.g. asking for a feature
Scope:3 - Applies to all machines and operating systems
Summary:Callback Update improvements
Created By:fabien
Assigned To:Unassigned
Fix Version:Unassigned
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

Post File ]

No files

Trouble Report Comments:

Post Text ]
Name/Time/Date Text top right image
#1 fabien
01:21 May 05, 2006
In discussing what to do for safe widget deletion from callback
functions, we have also talked about what to do about changed() -
in FLTK 1.1.x we clear changed() after a callback, which requires
access to the (potentially deleted) widget.

Retained proposals:

In order to avoid that sequence, and to preserve some measure of
API compatibility with 1.x, I propose the following changes to
the fltk::Widget class and related types and constants:

     1. Change the standard callback function prototype to:

        typedef void (Callback)(Widget *widget, void *user_data,
                                unsigned changed);

        The "changed" parameter would be a bitmask for the current
        changes to the widget.

     2. Change the "changed" flag from a simple boolean flag to a
        bitmask using the WHEN_* constants.

     3. Extend the WHEN_ constants to include user-defined and
        widget-specific conditions, e.g.:

        enum {
          WHEN_NEVER = 0,
          WHEN_CHANGED = 1,
          WHEN_NOT_CHANGED = 2,
          WHEN_RELEASE = 4,
          WHEN_RELEASE_ALWAYS = 6,
          WHEN_ENTER_KEY = 8,
          WHEN_ENTER_KEY_ALWAYS = 10,
          WHEN_ENTER_KEY_CHANGED = 11,
          WHEN_DRAGGED = 16,
          // ... other conditions ...
          WHEN_USER1 = 256,
          WHEN_USER2 = 512,
          WHEN_USER3 = 1024,
          WHEN_USER4 = 2048,
          WHEN_ALWAYS = ~0

     4. Change the implementation of do_callback() to accept a
        changed value and OR it with the widget's current value:

        void do_callback(unsigned changed = WHEN_CHANGED) {
          changed_ |= changed;
          if (callback_ && (when() & changed)) {
            (*callback_)(this, user_data_, changed);

     5. Change the implementation of changed(), set_changed(), and
        clear_changed() as follows:

        long changed_; // New field to hold changed() value

        long changed() const { return changed_; }
        void set_changed(long c = WHEN_CHANGED) { changed_ |= c; }
             void clear_changed(long c = WHEN_ALWAYS) { changed_ &= ~c; }

     6. Document that the callback/program is responsible for clearing
        the changed() value, and that changed() will contain the
        bitwise OR of all changes that have occurred with the
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 ''.