>
> I think, subclassing is not enough to stop loosing the FOCUS. (Subclasses can
> have only replace() method. Others are not virtual)
>
I think you just have to return non-zero from
your subclass' handle() when stealing the focus
back. Like this.
Hope it helps,
Stan
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Enumerations.H>
#include <FL/Fl.H>
#include <cstring>
class RoachHotel : public Fl_Input {
public:
RoachHotel(int x, int y, int w, int h, char const* label = 0)
: Fl_Input(x, y, w, h, label)
{;}
int handle(int event)
{
if(event == FL_UNFOCUS) {
if(!ok()) {
take_focus();
return 1;
}
}
return Fl_Input::handle(event);
}
private:
bool ok() const
{
char const* v = value();
return !v || std::strcmp(v, "roach");
}
};
int main()
{
Fl_Double_Window win(300, 300);
new RoachHotel(100, 100, 100, 20);
new RoachHotel(100, 120, 100, 20);
new RoachHotel(100, 140, 100, 20);
new RoachHotel(100, 160, 100, 20);
win.end();
win.show();
return Fl::run();
}
~
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk