Change Widgets in Window or Change Window?

101 views
Skip to first unread message

J Foster

unread,
Sep 4, 2013, 6:24:43 PM9/4/13
to fltkg...@googlegroups.com
I am a begining FLTK user. I have put my widgets on the window, but when the return key is activated I want all widgets on the window to change... how do I do this?

MacArthur, Ian (Selex ES, UK)

unread,
Sep 5, 2013, 4:05:37 AM9/5/13
to fltkg...@googlegroups.com
> I am a begining FLTK user.

Welcome...

> I have put my widgets on the window, but when the
> return key is activated I want all widgets on the
> window to change... how do I do this?

Can you describe what you want to do in more detail? In what way do you want them to change?

Anyway, the general answer is probably that you put a button in that will catch the return key being pressed (possibly Fl_Return_Button, for example) and in its callback you walk the widget hierarchy and make the required changes to each widget.



Selex ES Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

Mike_W

unread,
Sep 5, 2013, 1:30:29 PM9/5/13
to fltkg...@googlegroups.com
Here's what I would do. I tested this. Worked fine.  I'm assuming that you want to replace one set of widgets with an entirely different set of widgets when the 'Return' key is pressed.  First put the first set of widgets in Group 1 and the second set in Group 2.  Groups can be displayed and hidden with the ->show and ->hide methods. Next add an invisible button that is not in either of the groups. Set the box type of the invisible button to ->box(FL_NO_BOX). It doesn't have to be invisible. I'm assuming that's what you want. Set the shortcut of the invisible button to ->shortcut(0xff0d), which is the 'Return' or 'Enter' key. In the callback of the invisible button show Group 1 / hide Group 2, or hide Group 1 / show Group 2 depending of button's value.

J Foster

unread,
Sep 5, 2013, 4:15:27 PM9/5/13
to fltkg...@googlegroups.com
Ian and Mike,
 
Ian, I see what you are saying I believe... when the event takes place I change the values of the widget I want to update on the window. Example, I hit enter and I change the text on a label when I hit the button. Thank you that was a question I did have.
 
Mike, I believe this is pretty much right on what my problem was yesterday, though I do have further questions...
 
#include <FL/Fl.H> 
#include <FL/Fl_Window.H> 
#include <FL/Fl_Box.H> 
 
int main(int argc, char **argv) { 
 
Fl_Window *window = new Fl_Window(340,180); 
 
Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!"); 
  box
->box(FL_UP_BOX); 
  box
->labelfont(FL_BOLD+FL_ITALIC); 
  box
->labelsize(36); 
  box
->labeltype(FL_SHADOW_LABEL);

  //assume the vales of the arguments below are legitimate
  Fl_Button *button = new Fl_Button(x, y, width, height, "label");

  window->end();
  window->show(argc, argv); 
 
return Fl::run(); 
}
First, the above code snipit would be altered to display a box and a button below. I would alter the size of the window and whatnot.
So we have a button and a box... when I hit the button I want both to disappear and some other entirely different widgets to appear.

Where do I group these widgets? Within main() or outside main()? Code examples are genuinely appreciated.

J Foster

unread,
Sep 5, 2013, 4:36:33 PM9/5/13
to fltkg...@googlegroups.com
Actually I am googling how to group things in FLTK and I do not understand.
 
Would someone be kind enough to please demostrate or link to a demotration?

Ian MacArthur

unread,
Sep 5, 2013, 4:51:28 PM9/5/13
to fltkg...@googlegroups.com

On 5 Sep 2013, at 21:36, J Foster wrote:

> Actually I am googling how to group things in FLTK and I do not understand.
>
> Would someone be kind enough to please demostrate or link to a demotration?


Have you looked at the worked examples in the test and examples folders of the tarball?

Also, you probably need to take a look at Greg's cheat-sheet and his video's:

http://seriss.com/people/erco/fltk/

And google about for the other fltk tutorial videos, such as the tutorials by Robert Arkiletian here:

http://www3.telus.net/public/robark/





Greg Ercolano

unread,
Sep 5, 2013, 4:57:01 PM9/5/13
to fltkg...@googlegroups.com
On 09/05/13 13:15, J Foster wrote:
> when I hit the button I want both to disappear and some other
> entirely different widgets to appear.

This sure sounds a lot like a 'wizard', i.e. Fl_Wizard..
where you push a button ("Next") and proceed through
different screens of widgets.

Would that fit your application? ie:
http://seriss.com/people/erco/fltk/#Fl_Wizard

Basically this is just a matter of making different
Fl_Group's that overlap, each with different widgets inside them,
and then making them all hidden with hide() except one. Then when
you want to show the next screen, you hide() the current, and show()
the next.

Groups can be used like pages in a book; they can each be arranged
in an overlapping fashion, and each group (or 'page') can contain
different widgets.

This can be built in fluid, or build in code.
See the Fl_Wizard example which shows how to make the overlapping
groups. All the wizard widget does for you is make sure only one
group is ever on at a time, and makes it easy to manage the groups
'in order'. In other words, it doesn't do much, and you could do it
yourself without the wizard widget.

Greg Ercolano

unread,
Sep 5, 2013, 5:06:27 PM9/5/13
to fltkg...@googlegroups.com
On 09/05/13 13:36, J Foster wrote:
> Actually I am googling how to group things in FLTK and I do not understand.
> Would someone be kind enough to please demostrate or link to a demotration?

The wizard link in my last message shows examples of how to
create groups.

Basically:

// Create a group with two buttons in it
Fl_Group *grp1 = new Fl_Group(X,Y,W,H); // start the group definition
grp1->begin(); // (this is implied, but good practice to specify)

// define widgets here that will go into this 'grp1' group
Fl_Button *but1 = new Fl_Button(..);
Fl_Button *but2 = new Fl_Button(..);

// Now 'end' the group
grp1->end();

Then you can then turn the group on and off with:

grp1->hide(); // 'hide' the group; it and its children will disappear from view
grp1->show(); // 'show' the group (and its two children, the buttons)

The group and its widgets remain allocated when hidden; they're just
removed from view and can't be 'clicked' until show()n again.

J Foster

unread,
Sep 5, 2013, 5:10:56 PM9/5/13
to fltkg...@googlegroups.com
Thanks again Ian

J Foster

unread,
Sep 5, 2013, 5:11:33 PM9/5/13
to fltkg...@googlegroups.com, erco_...@seriss.com
Thanks a lot Greg

J Foster

unread,
Sep 5, 2013, 8:37:29 PM9/5/13
to fltkg...@googlegroups.com
Hey guys...
 
My program starts out like "int main(int argc, char **argv) { ... }" do I need to include these in window->show(argc, argv) or anything?

Greg Ercolano

unread,
Sep 5, 2013, 8:47:16 PM9/5/13
to fltkg...@googlegroups.com
On 09/05/13 17:37, J Foster wrote:
> Hey guys...
>
> My program starts out like "int main(int argc, char **argv) { ... }" do I need to include these in window->show(argc, argv) or anything?

Passing argc,argv to show() is optional.
You can just call show() with no args.

Use it if you want to support the optional FLTK flags in your apps command line.
See -help for info.

There are flags like -scheme, -geometry and -icon that are sometimes useful.

Invoking one of the linux FLTK demos with -help shows these flags:

# ./demo -help
Usage: ./demo <switches> <menufile>
-bg2 color
-bg color
-di[splay] host:n.n
-dn[d]
-fg color
-g[eometry] WxH+X+Y
-i[conic]
-k[bd]
-na[me] classname
-nod[nd]
-nok[bd]
-not[ooltips]
-s[cheme] scheme
-ti[tle] windowtitle
-to[oltips]

J Foster

unread,
Sep 5, 2013, 10:07:28 PM9/5/13
to fltkg...@googlegroups.com, erco_...@seriss.com
Greg and Community,
 
So, I used the wizard widget to start going from window to window, and it is working perfectly.
 
Now my first page is an authentication page... or rather it looks like an authentication page. It is supposed to take two text field values then the submit button does callback(next_cb).
 
So the button then goes to a main menu, after the authentication page, compiled of several buttons. When a button is clicked I want to go to the next page... but not in chronological order... now how do I specify which page I want it to go to... refering to Erco's Cheat Page Wizard example we have pages 1, 2, 3, and say we have 4, 5, 6, ... I want to go from 1 to 2 then from 2 to 3 or 4 or 5 or 6 or... based off of an arbitrary choice of button on page 2.
 
Any insight or discussion is again greatly appreciated. I am enjoying using FLTK and this community. I will provide source code in this thread later just so you guys can see what I am working on.

Greg Ercolano

unread,
Sep 5, 2013, 11:47:52 PM9/5/13
to J Foster, fltkg...@googlegroups.com
On 09/05/13 19:07, J Foster wrote:
> refering to Erco's Cheat Page Wizard example we have pages 1, 2, 3, and say we have 4, 5, 6, ... I want to go from 1 to 2 then from 2 to 3 or 4 or 5 or 6 or... based off of an arbitrary choice of button on page 2.

Fl_Wizard has a value() method that lets you jump to a particular page (group).
So if your groups are named grp1, grp2, grp3.. and you have a callback for page #2's
button that wants to jump to page 6 (grp6), use G_wiz->value(grp6);


J Foster

unread,
Sep 6, 2013, 12:19:58 AM9/6/13
to fltkg...@googlegroups.com, J Foster, erco_...@seriss.com
Perfect!

J Foster

unread,
Sep 6, 2013, 12:39:40 AM9/6/13
to fltkg...@googlegroups.com, J Foster, erco_...@seriss.com
So, I am trying to do this...
 
                         
 
void back_cb (Fl_Widget*,void*) { ... }
 void arbitrary_cb (...) { G_wiz->value(gThree); }                        
 
I don't think I am understanding how to work with the value function because I tried the above as a possible call back without luck... says the gthree is unidentified...
 
I also tried...
 

oldTicketButton->callback(gFour); // I got gFour unidentified...

//I also tried

 
newTicketButton->callback(G_wiz->value(gThree)); // didn't work

On Thursday, September 5, 2013 10:47:52 PM UTC-5, Greg Ercolano wrote:

Greg Ercolano

unread,
Sep 6, 2013, 2:16:18 AM9/6/13
to fltkg...@googlegroups.com
On 09/05/13 21:39, J Foster wrote:
> void arbitrary_cb (...) { G_wiz->value(gThree); }
>
> I don't think I am understanding how to work with the value function
> because I tried the above as a possible call back without luck... says the gthree is unidentified...

Sounds like you don't have gThree defined as a global.

What you're running into here is not a problem using the value()
method so much as it is working with the scope of your variables.

In a callback, the only external variables you'll have access to are:

1) Arguments to the function
2) Globals

Since you're not passing gThree as an argument, it would have to
be a global.

To define gThree as a global, look at where the G_wiz variable
is declared. (Outside of main() and initialized to 0)

Do this same with gThree.

Also: note in the example code, it's using G_xxx as the naming
convention for globals, such as G_wiz. So you should do the same
with gThree; call it G_three instead, and use it this way:

Fl_Window *G_win = 0;
Fl_Wizard *G_wiz = 0;
Fl_Group *G_three = 0; // DECLARE IT HERE

..
void arbitrary_cb(...) { G_wiz->value(G_three); } // USE IT HERE
..

int main(..) {
G_win = new Fl_Window(400,300,"Example Wizard");
G_wiz = new Fl_Wizard(0,0,400,300);
..
// Wizard: page 3
G_three = new Fl_Group(..); // INITIALIZE IT HERE
..
}

That should get you on the right track I think.

> newTicketButton->callback(G_wiz->value(gThree)); // didn't work

No, that's just.. no.

That won't do anything you or the compiler would want;
that basically runs G_wiz->value(gThree) right away,
and tries to pass its void return value as the argument
to the newTicketButton->callback() method, which is just.. no ;)


MacArthur, Ian (Selex ES, UK)

unread,
Sep 6, 2013, 4:24:21 AM9/6/13
to fltkg...@googlegroups.com
You do not *have* to, but things will often work better if you do. In particular, passing the args to the first (and only the *first*) call of show will cause fltk to try and read in and apply the system default colours and etc for your current desktop.

MacArthur, Ian (Selex ES, UK)

unread,
Sep 6, 2013, 4:27:56 AM9/6/13
to fltkg...@googlegroups.com

> So, I am trying to do this...
 
                         
> void back_cb (Fl_Widget*,void*) { ... }
> void arbitrary_cb (...) { G_wiz->value(gThree); }                        
 
> I don't think I am understanding how to work with the
>value function because I tried the above as a possible
> call back without luck... says the gthree is unidentified...


Um... I don't want to appear harsh here (though what follows is going to look harsh anyway, sorry) but that's not a fltk question; that's just a basic variable scoping issue, as far as I can tell.

You maybe need to study your C/C++ books a bit more and it should all start making sense...


 
> newTicketButton->callback(G_wiz->value(gThree)); // didn't work

OK... and you need to read the fltk docs too then, from the look of things.

J Foster

unread,
Sep 6, 2013, 4:50:15 PM9/6/13
to fltkg...@googlegroups.com, ian.ma...@selex-es.com
Yes, a bit harsh... though I am not offended... in fact that's why I am here in order to get help to improve my programming skills. I have taken a total of five computer programming classes. I am interested in software and would like to work in the field... so I guess I will do whatever to keep learning.
 
I have gotten very burned out working with the console, and that is the reason my fundamental skills are in question here. I have decided to keep my mind happy I will force myself to work with GUI.

J Foster

unread,
Sep 6, 2013, 4:53:03 PM9/6/13
to fltkg...@googlegroups.com, erco_...@seriss.com
Thank you Greg this clarifies my issue.
 
To Greg and Ian, I actually could have guessed this was an issue more directly related to variable scope rather than FLTK... because the error was an unidentified value. I may seem slow on uptake, but I am so burned out reading documentation lately I had to get my hands dirty.

Ian MacArthur

unread,
Sep 6, 2013, 5:56:22 PM9/6/13
to fltkg...@googlegroups.com

On 6 Sep 2013, at 21:50, J Foster wrote:

> Yes, a bit harsh... though I am not offended...

Email can be a somewhat impersonal forum - so just keep plugging away, keep asking the questions.
Don't get freaked if the answers seem a bit brusque...


> in fact that's why I am here in order to get help to improve my programming skills. I have taken a total of five computer programming classes. I am interested in software and would like to work in the field... so I guess I will do whatever to keep learning.

No real substitute for putting the time in writing examples: you learn a lot more from getting it wrong than you do from books!




J Foster

unread,
Sep 9, 2013, 11:30:14 PM9/9/13
to fltkg...@googlegroups.com
 
 
    
 
//assume all includes are here
Fl_Window *G_win = 0;
Fl_Wizard *G_wiz = 0;
/* now groups 1 through 4 are declared and the pointer is initialized to 0 as Fl_Group *G_one = 0;... replace one with respective number*/   
void back_cb(Fl_Widget*,void*) { G_wiz->prev(); }
void next_cb(Fl_Widget*,void*) { G_wiz->next(); }
void done_cb(Fl_Widget*,void*) { exit(0); }

void G_three_cb (Fl_Widget*,void*) { G_wiz->value(G_three); }
//void G_four... ...

// code similar to Erco's FLTK Cheat Page Wizard example

 
When I call my arbitrary callback for either page 3 or page 4... only page 4 displays. I will provide further code snips if needed.

Greg Ercolano

unread,
Sep 9, 2013, 11:46:08 PM9/9/13
to fltkg...@googlegroups.com
On 09/09/13 20:30, J Foster wrote:
> When I call my arbitrary callback for either page 3 or page 4... only page 4 displays.
> I will provide further code snips if needed.

Yes, show the complete program.

Greg Ercolano

unread,
Sep 9, 2013, 11:54:57 PM9/9/13
to fltkg...@googlegroups.com
BTW, just made this little test program which seems to show
the absolute value() method works OK; I added three buttons
along the bottom of the window that let you jump to any one
of the three pages:

#include <stdlib.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Wizard.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Multiline_Output.H>

// Simple 'wizard' using fltk's new Fl_Wizard widget

Fl_Window *G_win = 0;
Fl_Wizard *G_wiz = 0;
Fl_Group *G_grp1 = 0;
Fl_Group *G_grp2 = 0;
Fl_Group *G_grp3 = 0;

void back_cb(Fl_Widget*,void*) { G_wiz->prev(); }
void next_cb(Fl_Widget*,void*) { G_wiz->next(); }
void done_cb(Fl_Widget*,void*) { exit(0); }
void absolute_cb(Fl_Widget*,void*grp) { G_wiz->value((Fl_Group*)grp); }
int main(int argc, char **argv) {
G_win = new Fl_Window(400,350,"Example Wizard");
G_wiz = new Fl_Wizard(0,0,400,300);

// Wizard: page 1
{
G_grp1 = new Fl_Group(0,0,400,300);
Fl_Button *next = new Fl_Button(290,265,100,25,"Next"); next->callback(next_cb);
Fl_Multiline_Output *out = new Fl_Multiline_Output(10,30,400-20,300-80,"Welcome");
out->labelsize(20);
out->align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
out->value("This is First page");
G_grp1->end();
}
// Wizard: page 2
{
G_grp2 = new Fl_Group(0,0,400,300);
Fl_Button *next = new Fl_Button(290,265,100,25,"Next"); next->callback(next_cb);
Fl_Button *back = new Fl_Button(180,265,100,25,"Back"); back->callback(back_cb);
Fl_Multiline_Output *out = new Fl_Multiline_Output(10,30,400-20,300-80,"Terms And Conditions");
out->labelsize(20);
out->align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
out->value("This is the Second page");
G_grp2->end();
}
// Wizard: page 3
{
G_grp3 = new Fl_Group(0,0,400,300);
Fl_Button *done = new Fl_Button(290,265,100,25,"Finish"); done->callback(done_cb);
Fl_Button *back = new Fl_Button(180,265,100,25,"Back"); back->callback(back_cb);
Fl_Multiline_Output *out = new Fl_Multiline_Output(10,30,400-20,300-80,"Finish");
out->labelsize(20);
out->align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
out->value("This is the Last page");
G_grp3->end();
}
G_win->begin();
Fl_Button *b1 = new Fl_Button(10, 310,50,25,"1"); b1->callback(absolute_cb, (void*)G_grp1);
Fl_Button *b2 = new Fl_Button(70, 310,50,25,"2"); b2->callback(absolute_cb, (void*)G_grp2);
Fl_Button *b3 = new Fl_Button(130,310,50,25,"3"); b3->callback(absolute_cb, (void*)G_grp3);
G_wiz->end();
G_win->end();
G_win->show(argc, argv);
return Fl::run();
}

J Foster

unread,
Sep 10, 2013, 12:12:17 AM9/10/13
to fltkg...@googlegroups.com, erco_...@seriss.com
I do not have internet access at this time for the computer I am programming on. I will provide the full program tomorrow. Thank you for the example program. This example may solve my problem... though I will share my source anyway as to show you guys what you've been assisting with.

J Foster

unread,
Nov 5, 2013, 6:51:14 AM11/5/13
to fltkg...@googlegroups.com, erco_...@seriss.com
/*

* * *

AS OF 10/06/2013 MY QUESTION TO THE FLTK FORUM...

So This program DOES NOT RESEMBLE what I have envisoned for the final product
the first problem I have run into is when I try to use a button within
group 1 to change to group 2 it actually changes the window to group 3...
well it changes the wizard not the window but whatever...

Can you guys help with this problem?

I have documented code below. As I edit I plan to add notes above...

* * *

*/


#include <stdlib.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Wizard.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Multiline_Output.H>

// Simple 'wizard' using fltk's new Fl_Wizard widget
/*INCLUDING PIECES OF CODE WRITTEN BY Greg Ercolano VIA FLTK FOURM POSTS

Imagine that we have an electric company or telecommunications company
we have various cords and connections that create our infrastructure...

Each piece of infrastructure will be tracked via an ID

. . . MORE TO BE SAID LATER 10/06/2013

*/


Fl_Window *G_win  = 0;
Fl_Wizard *G_wiz  = 0;
Fl_Group  *G_grp1 = 0;
Fl_Group  *G_grp2 = 0;
Fl_Group  *G_grp3 = 0;

void back_cb(Fl_Widget*,void*) { G_wiz->prev(); }
void next_cb(Fl_Widget*,void*) { G_wiz->next(); }
void done_cb(Fl_Widget*,void*) { exit(0); }
void absolute_cb(Fl_Widget*,void*grp) { G_wiz->value((Fl_Group*)grp); }
int main(int argc, char **argv) {

   
/*COMPARED TO YOUR EXAMPLE THIS WINDOW HEIGHT IS ALTERED*/
    G_win
= new Fl_Window(400,300,"Trouble Ticketing System");
    G_wiz
= new Fl_Wizard(0,0,400,300);

   
// Wizard: page 1
   
{
       
/* So here I changed out the multiline output and button to be a new button with an attempt
        to use a call back to display group 2 though each time the button is pressed group 3 displays.
       
        Can you guys help me figure that out?*/

        G_grp1
= new Fl_Group(0,0,400,300);
       
//THIS BUTTON IS THE BUTTON EXPERIENCING PROBLEMS
       
Fl_Button *groupTwoSwitch = new Fl_Button(10,30,120,30,"Ticket Create");
        groupTwoSwitch
->callback(absolute_cb, (void*)G_grp3);

       
/*THIS IS OLD CODE

       
        Fl_Button *next = new Fl_Button(290,265,100,25,"Next"); next->callback(next_cb);
        Fl_Multiline_Output *out = new Fl_Multiline_Output(10,30,400-20,300-80,"Welcome");
        out->labelsize(20);
        out->align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
        out->value("This is First page");*/
       
        G_grp1
->end();

   
}
   
// Wizard: page 2
   
{
        G_grp2
= new Fl_Group(0,0,400,300);
       
Fl_Button *next = new Fl_Button(290,265,100,25,"Next"); next->callback(next_cb);
       
Fl_Button *back = new Fl_Button(180,265,100,25,"Back"); back->callback(back_cb);
       
Fl_Multiline_Output *out = new Fl_Multiline_Output(10,30,400-20,300-80,"Terms And Conditions");
       
out->labelsize(20);
       
out->align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
       
out->value("This is the Second page");
        G_grp2
->end();
   
}
   
// Wizard: page 3
   
{
        G_grp3
= new Fl_Group(0,0,400,300);
       
Fl_Button *done = new Fl_Button(290,265,100,25,"Finish"); done->callback(done_cb);
       
Fl_Button *back = new Fl_Button(180,265,100,25,"Back"); back->callback(back_cb);
       
Fl_Multiline_Output *out = new Fl_Multiline_Output(10,30,400-20,300-80,"Finish");
       
out->labelsize(20);
       
out->align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
       
out->value("This is the Last page");
        G_grp3
->end();
   
}
    G_win
->begin();

   
/*DUE TO THE WINDOW HEIGHT BEING LOWERED WE MUST COMMENT OUT THE FOLLOWING THREE LINES*/
   
//Fl_Button *b1 = new Fl_Button(10, 310,50,25,"1"); b1->callback(absolute_cb, (void*)G_grp1);
   
//Fl_Button *b2 = new Fl_Button(70, 310,50,25,"2"); b2->callback(absolute_cb, (void*)G_grp2);
   
//Fl_Button *b3 = new Fl_Button(130,310,50,25,"3"); b3->callback(absolute_cb, (void*)G_grp3);
    G_wiz
->end();
    G_win
->end();
    G_win
->show(argc, argv);
   
return Fl::run();
}

So here is the program. I wrote earlier some stuff about questions or something in the code. I will ask more soon.

Greg Ercolano

unread,
Nov 5, 2013, 11:18:01 AM11/5/13
to fltkg...@googlegroups.com
> the first problem I have run into is when I try to use a button within
> group 1 to change to group 2 it actually changes the window to group 3...

You're passing the value of group3 (G_grp3) before it's been initialized:

> groupTwoSwitch->callback(absolute_cb,(void*)G_grp3); // <-- PASSING VALUE HERE BEFORE IT'S INITIALIZED
> [stuff]
> G_grp3 =new Fl_Group(0,0,400,300); // <-- INITIALIZED HERE

Since G_grp3 is a global, you don't need to pass it as userdata
anyway, you can probably make you code work by making this change:

BEFORE: void absolute_cb(Fl_Widget*,void*grp) { G_wiz->value((Fl_Group*)grp); }
AFTER: void absolute_cb(Fl_Widget*,void*) { G_wiz->value(G_grp3); }

This way the value is resolved at the time the callback is invoked,
not at the time the callback is set.

If you /did/ want to pass G_grp3 as userdata, but have it initialized
later, then perhaps you'd want to pass a pointer to the variable
instead of the value of the variable.

Reply all
Reply to author
Forward
0 new messages