> hello:
> My interface is composed of two windows.window1 has a button named button1 
> whose shortcut is F1,window2 has a button named button2 whose shortcut is F2.
> When window1 get focus,I can press F1 active button1,but I can’t press F2 
> active button2.
> My problem is How can I press F2 active button2 when window1 get focus?
> Thanks.
>

Assuming you are using Fltk 1.1x, I believe the solution is to use the 
Fl::add_handler function described here: 
http://www.fltk.org/doc-1.1/Fl.html#Fl.add_handler.

For me, the following code accomplishes what you describe:

#include <FL/Fl.h>
#include <FL/Fl_Window.h>
#include <FL/Fl_Button.h>
#include <iostream>

int global_handler(int event){

if(event==FL_SHORTCUT){
if(Fl::event_key()==(FL_F+1))
std::cout <<"button1\n";
else if(Fl::event_key()==(FL_F+2))
std::cout << "button2\n";
}
}

int main(void){
Fl_Window w1(0,0,100,100,"w1");
Fl_Button b1(0,0,100,100,"button1");
w1.end();
w1.show();
Fl_Window w2(100,0,100,100,"w2");
Fl_Button b2(0,0,100,100,"button2");
w2.end();
w2.show();
Fl::add_handler(global_handler);
return Fl::run();
}

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to