summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fl_cursor.cxx7
-rw-r--r--test/cube.cxx9
-rw-r--r--test/subwindow.cxx11
3 files changed, 25 insertions, 2 deletions
diff --git a/src/fl_cursor.cxx b/src/fl_cursor.cxx
index 06d9858c8..651c098d5 100644
--- a/src/fl_cursor.cxx
+++ b/src/fl_cursor.cxx
@@ -59,8 +59,13 @@ void Fl_Window::default_cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
# define IDC_HAND MAKEINTRESOURCE(32649)
# endif // !IDC_HAND
-void Fl_Window::cursor(Fl_Cursor c, Fl_Color, Fl_Color) {
+void Fl_Window::cursor(Fl_Cursor c, Fl_Color c1, Fl_Color c2) {
if (!shown()) return;
+ // the cursor must be set for the top level window, not for subwindows
+ Fl_Window *w = window(), *toplevel = this;
+ while (w) { toplevel = w; w = w->window(); }
+ if (toplevel != this) { toplevel->cursor(c, c1, c2); return; }
+ // now set the actual cursor
if (c == FL_CURSOR_DEFAULT) {
c = cursor_default;
}
diff --git a/test/cube.cxx b/test/cube.cxx
index 9abf442ad..09e50f5b6 100644
--- a/test/cube.cxx
+++ b/test/cube.cxx
@@ -54,6 +54,7 @@ public:
class cube_box : public Fl_Gl_Window {
void draw();
+ int handle(int);
public:
double lasttime;
int wire;
@@ -123,6 +124,14 @@ void cube_box::draw() {
glEnable(GL_DEPTH_TEST);
}
+int cube_box::handle(int e) {
+ switch (e) {
+ case FL_ENTER: cursor(FL_CURSOR_CROSS); break;
+ case FL_LEAVE: cursor(FL_CURSOR_DEFAULT); break;
+ }
+ return Fl_Gl_Window::handle(e);
+}
+
#endif
Fl_Window *form;
diff --git a/test/subwindow.cxx b/test/subwindow.cxx
index 67b922309..a9fc7f45b 100644
--- a/test/subwindow.cxx
+++ b/test/subwindow.cxx
@@ -79,11 +79,13 @@ class testwindow : public Fl_Window {
int handle(int);
void draw();
int cx, cy; char key;
+ Fl_Cursor crsr;
public:
testwindow(Fl_Boxtype b,int x,int y,const char *l)
- : Fl_Window(x,y,l) {box(b); key = 0;}
+ : Fl_Window(x,y,l), crsr(FL_CURSOR_DEFAULT) {box(b); key = 0;}
testwindow(Fl_Boxtype b,int x,int y,int w,int h,const char *l)
: Fl_Window(x,y,w,h,l) {box(b); key = 0;}
+ void use_cursor(Fl_Cursor c) { crsr = c; }
};
#include <FL/fl_draw.H>
@@ -100,6 +102,12 @@ int testwindow::handle(int e) {
#ifdef DEBUG
if (e != FL_MOVE) printf("%s : %s\n",label(),eventnames[e]);
#endif
+ if (crsr!=FL_CURSOR_DEFAULT) {
+ if (e == FL_ENTER)
+ cursor(crsr);
+ if (e == FL_LEAVE)
+ cursor(FL_CURSOR_DEFAULT);
+ }
if (Fl_Window::handle(e)) return 1;
if (e == FL_FOCUS) return 1;
if (e == FL_PUSH) {Fl::focus(this); return 1;}
@@ -169,6 +177,7 @@ int main(int argc, char **argv) {
subwindow->resizable(subwindow);
window->resizable(subwindow);
subwindow->end();
+ subwindow->use_cursor(FL_CURSOR_HAND);
(new Fl_Box(FL_NO_BOX,0,0,400,100,
"A child Fl_Window with children of it's own may "
"be useful for imbedding controls into a GL or display "