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? Dave Jordan Jun 18, 2021  
 


On Fri, Jun 18, 2021 at 7:10 PM Greg Ercolano <erco@seriss.com> wrote:
On 6/18/21 10:18 AM, Dave Jordan wrote:
Subject: how can i declare & define Browser callback?
I haven't found any examples that use a subclassed Browser with .h & .cpp files.

    It sounds like you're looking for an example that subclasses Fl_Hold_Browser
    and uses callbacks, so an example of that might be:


#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Hold_Browser.H>

// Demonstrate subclassing Fl_Hold_Browser and using callback -erco 6/18/21

class MyBrowser : public Fl_Hold_Browser {
right, i did see examples in various places including your cheat page and the examples dir, but again, no "MyBrowser.h" or the like was in evidence, so I wasn't sure about the decl.
I had some simple compile error to start with, i dont even remember what, and then i got too complicated trying to fix it.
this is how I have it now:

#ifndef BRWSR_H
#define BRWSR_H
#include "glbl.h"         // include various FL widget headers

struct Brwsr : Fl_Hold_Browser {
Brwsr(int x, int y, int w1, int w2, int h);
void brwsr_cb(Fl_Widget*, void *v);
};
#endif // BRWSR_H
**********************************
#include yada yada.h
Brwsr::Brwsr(int x, int y, int w1, int w2, int h) : Fl_Hold_Browser(x, y, w1 + w2, h) {
// set appearance properties
}
void Brwsr::brwsr_cb(Fl_Widget *w, void *v) {     // use browser widget to control which game is displayed (what did i see it called? vertical tabbed dialog?)
Brwsr *b = (Brwsr*) w;
if(b->value() > 0) {
Game *gm = (Game*) v;
// unload app->cur.game
// load Game* gm
// assign gm to app->cur.game
// etc...
}
}

--
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/CAPdW6bKm%2BkSrD3MByagCvwxmXOR7tgCSQY%3Dq4QbKWb0_-Qe2Mg%40mail.gmail.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'.