FLTK logo

[branch-1.4] d3af349 - Fix documentation of fl_overlay_clear and fl_overlay_rect

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
[  All Forums  |  Back to fltk.commit  ]
 
[ Previous Message ] [ Next Message ]

[branch-1.4] d3af349 - Fix documentation of fl_overlay_clear and fl_overlay_rect "Albrecht Schlosser" Jul 24, 2025  
 
commit d3af349f88c2f99cc0b3aebe41354a851ff78c0b
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Thu Jul 24 15:40:18 2025 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Thu Jul 24 15:42:19 2025 +0200

    Fix documentation of fl_overlay_clear and fl_overlay_rect
    
    The code example in fl_overlay_clear() wouldn't work.
    
    Backported from: b00ae1eee42c102f577189e7fb095a4a4ea37f02

 src/fl_overlay.cxx | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git src/fl_overlay.cxx src/fl_overlay.cxx
index 82e4a13..247a911 100644
--- src/fl_overlay.cxx
+++ src/fl_overlay.cxx
@@ -97,26 +97,26 @@ void fl_overlay_clear() {
  of the widget.
 
  Your event handle should look similar to this (also see `test/mandelbrot.cxx`):
- ```
+ \code
   int MyWidget::handle(int event) {
-    static int ix, iy;
     switch (event) {
       case FL_PUSH:
-        ix = Fl::event_x(); iy = Fl::event_y();
+        ix = Fl::event_x(); // ix defined as (private) class member
+        iy = Fl::event_y(); // iy defined as (private) class member
         return 1;
       case FL_DRAG:
-        this->make_current();
-        fl_overlay_rect(ix, iy, ix-Fl::event_x(), iy-Fl::event_y());
+        window()->make_current();
+        fl_overlay_rect(ix, iy, Fl::event_x() - ix, Fl::event_y() - iy);
         return 1;
       case FL_RELEASE:
-        this->make_current();
+        window()->make_current();
         fl_overlay_clear();
         // select the element under the rectangle
         return 1;
     }
     return MySuperWidget::handle(event);
   }
- ```
+ \endcode
 
  \note Between drawing an overlay rect and clearing it, the content of the
     widget must not change.
[ Direct Link to Message ]
 
     
[ Previous Message ] [ Next Message ]
 
 

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