|
|
>then the callback is only being called when switching
to the first (n-1) tabs. I.e. if i have 4 tabs,
>"A","B","C", and "D", the callback is only called when
switching to "A", "B" or "C".
I don't see the issue.
I do. It's really strange.
I modified your example to show me which tab is active in the
callback, and the callback is invoked for all tabs. (gcc 9.3.0 on
Linux Mint 20).
Linux Mint 20 here as well.
$ g++ --version
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
I'm
uncertain what your test of tabs->value() was to accomplish in
the mywin handler, you will receive messages for the "previous"
tab (e.g. UNFOCUS) when switching to a new tab.
Kevin, the issue is not that you will receive the value of the
previous tab (which is true) but that the simple 'if ...' changes
the behavior. If I'm not missing anything obvious that's a mystery
(or really a C++ bug). Side note: I found another strange issue (a
nonsensical compiler warning) with this g++ version. It's maybe
really a bug.
I modified mywin::handle() like this:
int mywin::handle(int msg) { int ret = Fl_Double_Window::handle(msg); #if 1 if (tabs->value() == g1 && msg == FL_PUSH) printf("g1\n"); if (tabs->value() == g2 && msg == FL_PUSH) printf("g2\n"); if (tabs->value() == g3 && msg == FL_PUSH) printf("g3\n"); #endif return ret; }
If you change '#if 1' to '#if 0' the "callback behavior" changes as
described by the OP in the way that "In callback" is printed only when you switch tabs to tab 1
or tab 2 but not to the last tab. That's the effect I'm seeing, and
that is really unexpected. Particularly because the callback should
already have been called by 'Fl_Double_Window::handle(msg);' when
nthe following 3 statements are executed.
OK, I also built FLTK with clang and used debug and no-optimize (-g
-O0) switches but the result is the same.
The above seems to rule out a compiler bug.
(Some time later ...)
New tests showed that calling tabs->value() appears to have a side effect
that makes this issue happen. For anybody to reproduce the issue my
further modified handle() looks like this:
int mywin::handle(int event) { int ret = Fl_Double_Window::handle(event); #if 0 void *pp = tabs->value(); // std::cerr << "tabs->value() =" << pp << std::endl; #else const char *pp = tabs->label() ? tabs->label() : "none"; // std::cerr << "tabs->label() = " << pp << std::endl; #endif return ret; }
Note: if you comment out the output statements as shown above, make
sure that the compiler doesn't optimize the calls away. It shouldn't
do that with tabs->value() because it's not 'const', but anyway.
Take care.
Now change '#if 0' to '#if 1' and watch the result:
(1) With '#if 0' tabs->label() is called and the code works as
expected.
(2) With '#if 1' tabs->value() is called and the code fails to
show "In callback" for the last tab.
BTW: I would have expected that Fl_Tabs::value() is a 'const' method
but it isn't. Except returning the "current tab" value it does also
show/hide tabs. This seems to have to do with this unexpected
effect.
Still testing ...
--
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/dcd7c9e9-01a1-48de-6304-3021d2837bca%40online.de.
[ Direct Link to Message ] | |
|
| |