On 24/03/11 14:14, Manolo Gouy wrote:
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR Pending]

Link: http://www.fltk.org/str.php?L2594
Version: 1.3.0
Fix Version: 1.3.0 (r8530)


Please apply r. 8530. It solves the issue raised by your
first test program.

The focus was indeed not correctly done after a window was created
because some code present in the Carbon version was not reflected
in the Cocoa version. This code has now been added.

As for the second test program: the
   win->take_focus();
statement does not change the focus to the large window because
there's no focus-accepting widget in this window. Therefore
the focus remains to the small window that gets closed by cmd-W.
I believe its's not a bug that an empty window can't be given
the focus by the take_focus() function.
If you replace win->take_focus() by
   Fl::focus(win);
the expected behavior is observed, because the focus does get
set to the large window.

If you add a focus-accepting widget in the large window, as in the
attached focus3.cxx, the expected behavior is observed, both
with and without the r.8530 Cocoa fix.

Please, post your observations so I know whether to close this STR.


Hi Manolo - r8530 indeed fixes the first issue: awesome!

I still observe the second issue either with win->take_focus() or with Fl::focus(win). (In my code my window event handler accepts the FL_FOCUS and FL_UNFOCUS events.)

Attached is a new small example using either win->take_ficus() or Fl::focus(win). Both do not seem to work as expected.



Link: http://www.fltk.org/str.php?L2594
Version: 1.3.0
Fix Version: 1.3.0 (r8530)

// 1) launch program; two windows are shown
// 2) press 'Command-w':
//     - expected behaviour: the large window should be closed (thanks to 
//       the take_focus() call in main())
//     - observed behaviour: the smallt window is closed

#include <stdio.h>
#include <stdlib.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>

class myWindow : public Fl_Window {
 private:
  int handle(int event)
  {
    switch (event) {
    case FL_FOCUS:
    case FL_UNFOCUS:
      return 1;
    case FL_SHORTCUT:
    case FL_KEYBOARD:
      if(Fl::test_shortcut(FL_META+'w')){
        do_callback();
        return 1;
      }
      break;
    }
    return Fl_Window::handle(event);
  }
 public:
  myWindow(int w, int h, const char *l=0) 
    : Fl_Window(w, h, l) {}
};

myWindow *win, *win2;

int main(int argc, char **argv)
{
  win = new myWindow(200, 200);
  win->show(argc, argv);

  win2 = new myWindow(100, 100);
  win2->show();

  // this does not work:
  //win->take_focus();

  // this does not work either
  Fl::focus(win);

  return Fl::run();
}
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to