24.03.2007 michael sephton <[EMAIL PROTECTED]> wrote:
> Hi, Here is a similar demo program for fltk 1.1x. You type in an input in
> one window, and as soon as you type it pops up another window with an
> input, and it retains the focus, and as you continue typing, it updates the
> text in the second window.
>
> #include <FL/Fl.h>
> #include <FL/Fl_Window.h>
> #include <FL/Fl_Input.h>
> #include <Fl/Fl_Button.h>
> #include <iostream>
>
> Fl_Window *win;
> Fl_Input *in;
> Fl_Window *ext_win;
> Fl_Input *ext_in;
> Fl_Button *hide_button;
>
> void hide_cb(Fl_Widget *w,void *d){
> if(ext_win->visible())
> ext_win->hide();
> }
>
> void in_cb(Fl_Widget *w,void *d){
> if(!ext_win->visible())
> ext_win->show();
> ext_in->value(in->value());
> in->take_focus();
>
> }//in_cb
>
> int main(void){
>
> win=new Fl_Window(0,100,100,30,"window");
> in=new Fl_Input(0,0,100,30);
> in->callback(in_cb,0);
> in->when(FL_WHEN_CHANGED);
> win->end();
> win->show();
> ext_win=new Fl_Window(0,0,300,50,"extended window");
> ext_in=new Fl_Input(0,0,300,30);
> hide_button=new Fl_Button(5,35,45,15,"Hide");
> hide_button->callback(hide_cb);
> ext_win->end();
> ext_win->hide();//see comment below
>
> return Fl::run();
> }
>
> BTW I noticed that if I don't explicitly hide this window
> ext_win->visible() returns 1, even though the window is not shown.. is this
> a feature or a bug?
Thanks for your effort Michael, but this program also (in FLTK 2.x) retains
the same behaviour. The following is the FLTK 2.x version of your program:
--- Start ---
#include <fltk/run.h>
#include <fltk/Window.h>
#include <fltk/Input.h>
#include <fltk/Button.h>
using namespace fltk;
Window *win;
Input *in;
Window *ext_win;
Input *ext_in;
Button *hide_button;
void hide_cb(Widget *w,void *d){
if(ext_win->visible())
ext_win->hide();
}
void in_cb(Widget *w,void *d){
if(!ext_win->visible())
ext_win->show();
ext_in->value(in->value());
in->take_focus();
}//in_cb
int main(void) {
win=new Window(0,100,100,30,"window");
win->begin();
in=new Input(0,0,100,30);
in->callback(in_cb,0);
in->when(WHEN_CHANGED);
win->end();
win->show();
ext_win=new Window(0,0,300,50,"extended window");
ext_win->begin();
ext_in=new Input(0,0,300,30);
hide_button=new Button(5,35,45,15,"Hide");
hide_button->callback(hide_cb);
ext_win->end();
ext_win->hide();//see comment below
return run();
}
--- End ---
And this program also, when I type the first character gives focus to
second window, that is, to its input in that window, so the rest of typing is
going to that second window, except if I don't manually refocus (click by
mouse) first window, after which I can continue typing in first window with
its value being copied to second window's input, which is desired/intended
behaviour.
So your program basically behaves in the same way like mine.
I don't know if this is a bug in FLTK 2.x if this WORKS as is supposed to in
FLTK 1.x.
Also there is one interesting thing about this program, if I omit
"win->begin()" and "ext_window->begin()" windows wont have inputs, which
is IMO opinion very good thing, because it gives standard to it, and forces
programmer to use "begin()" with witch code is much more understandable and
cleaner. That is if this is intentional.
But let's not stray away from the main problem, I've tried almost everyting:
"browser->throw_focus()", "browserWindow->throw_focus()", "take_focus()",
"wordInput->take_focus()" and before that in constructor:
"browser->flags(INACTIVE)", "browserWindow->flags(INACTIVE),
"browser->flags(INACTIVE_R)" and "browserWindow->flags(INACTIVE_R)", and
always the first typed character gives focus to second window.
I'm using FLTK 2.x svn revision r5697 (one or two weeks ago, I've tried newer
revisions, but they wouldn't compile).
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk