1

I am trying to change the cursor inside a FLTK window: the following code

#include "FL/Fl.H"
#include "FL/Fl_Double_Window.H"

Fl_Cursor CUR_DEF = FL_CURSOR_HAND;

int main(){
    Fl_Double_Window* W = new Fl_Double_Window(200,200,"test");
    W -> cursor(CUR_DEF);
    W -> show();
    return Fl::run();
}

does not work, and it does not work even using default_cursor(CUR_DEF). But as soon as I move W -> cursor(CUR_DEF); after W -> show(), the hand cursor appears if I firstly move the cursor on the window's title bar (in this case, "test") or if I firstly move the window across the screen. Why the right cursor is not appearing when the program is launched?

Moreover, when the cursor leaves the window and enter again, the cursor returns to be the system one, and becomes the "hand" only if it passes over the title bar.

I am using FLTK 1.3.5, clang version 14.0.0, on a MacBook pro.

1 Answer 1

2

FLTK 1.3.5 is more than 5 years old (March 2019), you should really use a newer version. Current stable release is 1.3.9, and 1.4.0 is the development version (git only).

In FLTK 1.4.0 it is documented behavior that "the window must be show()'n for this function to have any effect". This answers the main part of your question. Unfortunately this bit of information is missing in the 1.3 documentation but it applies to this version as well.

I tested your program after moving the cursor assignment below the show() statement, using FLTK 1.3 (release 1.3.9 and git branch-1.3) and FLTK 1.4.0 (git master) and I can confirm your report only partially. In my test on macOS I found that the cursor is assigned immediately when the pointer enters the window from any side (left, right, bottom) except from the top (crossing the title bar). I did NOT test FLTK 1.3.5.

I'm going to open a bug report (GitHub Issue) for FLTK 1.4.0. Note that there are similar issues on the new Wayland platform (1.4 only). I'll let you and others know the issue number and a link shortly. I will also post a slightly modified version of your test program to the issue.

Side note: you should also change the #include statements to use <...> rather than double quotes (the exact reason why this is useful would be OT here).

Sign up to request clarification or add additional context in comments.

6 Comments

FTR: please see FLTK Issue #1082 (github.com/fltk/fltk/issues/1082).
FTR: The macOS bug has been fixed today in commit ea80a31266be626525728f7b3d73323353d42c25. Thanks to our macOS expert Manolo.
You're completely right, I've been really lazy and did not update the FLTK distribution since I am using it for my small home project and not for work. Thanks for reporting the issue and for helping in fixing it in newer release. Yep, sometimes I mix using <...> with "..." when I include some custom header files and library files.
Now I recall why I never installed the new version: I am trying just now, and I get this error after the make command : /opt/local/bin/ranlib: object: ../lib/libfltk_forms.a(forms_compatability.o) malformed object (unknown load command 1) /opt/local/bin/ar: internal ranlib command failed
Only a quick comment w/o going too far OT: please try a full build in a new build folder, and I suggest to use CMake if you didn't. CMake is much better in maintaining dependencies. There are lots of other possibilities for such an error message, particularly on macOS if you're using homebrew or other additional tools. Please open a separate question, preferably on fltk.general (groups.google.com/g/fltkgeneral).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.