FLTK logo

Re: [fltk.general] how can i declare & define Browser callback?

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 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: how can i declare & define Browser callback? Ian MacArthur Jun 18, 2021  
 
On 18 Jun 2021, at 18:18, Dave Jordan wrote:
> 
> I haven't found any examples that use a subclassed Browser with .h & .cpp files.

Ummm, OK... What are you wanting to achieve? Your sample code looks a wee bit... odd.

Have you looked at examples/howto-browser-with-icons.cxx - does that not show what you need?
And of course test/browser.cxx.


> brwsr.h
> #include <FL/Fl.H>
> #include <FL/Fl_Hold_Browser.H>
> struct Brwsr : Fl_Hold_Browser {

That’s “unconventional", I would suggest, subclassing a class object as a struct. That would not be considered idiomatic C++ code, generally.


> callback(brwsr_cb);
> // more callback-related decls?
> }


What are you planning on doing, with a subclassed callback method? That’s not what folks usually do - the callback method is pretty generic, so you can pass it pretty much any callback function to call.


> 
> brwsr.cpp
> #include "brwsr.h"
> Brwsr::Brwsr() {
> void brwsr_cb2();
> static void brwsr_cb(Fl_Widget*,void *v) {
> ((Brwsr*)v)->brwsr_cb();
> }
> }
> Brwsr::brwsr_cb2() { ... }
> 
> -- 
> You received this message because you are subscribed to the Google Groups "fltk.general" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/CAPdW6bLwnBPWGWOJCrnvg6QdQbiZYk3cZ0btb5Teh3huwNv8UQ%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/47222533-21F7-41E5-899F-B1B69AE2A98E%40gmail.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

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 'erco@seriss.com'.