SDL_ShowCursor

Hello !

One thing that does not work correctly on Mac OSX
Panther or Tiger ist SDL_ShowCursor. When you use SDL_ShowCursor
(SDL_DISABLE) on a SDL_Window and the Mouse Cursor is in the Window
you have to move the cursor out of the window, then move it back
into it and then it will be hide.

When you use Fullscreen, the call SDL_ShowCursor (SDL_DISABLE) does
nothing. This is maybe the same problem as in window mode, but because
it is fullscreen you cannot move the cursor out of the window and into
it again.

CU

One thing that does not work correctly on Mac OSX
Panther or Tiger ist SDL_ShowCursor. When you use SDL_ShowCursor
(SDL_DISABLE) on a SDL_Window and the Mouse Cursor is in the Window
you have to move the cursor out of the window, then move it back
into it and then it will be hide.

When you use Fullscreen, the call SDL_ShowCursor (SDL_DISABLE) does
nothing. This is maybe the same problem as in window mode, but because
it is fullscreen you cannot move the cursor out of the window and into
it again.

This works correctly with the latest in CVS and the attached test
program, both run from the command line and launched from the Finder.

–ryan.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: test.c
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050820/9065dd1c/attachment.asc

Hello !

Yes, you are right. Maybe a bug in my code.

CU>> One thing that does not work correctly on Mac OSX

Panther or Tiger ist SDL_ShowCursor. When you use SDL_ShowCursor
(SDL_DISABLE) on a SDL_Window and the Mouse Cursor is in the Window
you have to move the cursor out of the window, then move it back into it
and then it will be hide.

When you use Fullscreen, the call SDL_ShowCursor (SDL_DISABLE) does
nothing. This is maybe the same problem as in window mode, but because it
is fullscreen you cannot move the cursor out of the window and into it
again.

This works correctly with the latest in CVS and the attached test
program, both run from the command line and launched from the Finder.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

On Mac OS 10.5, I can’t hide the mouse cursor
with SDL_ShowCursor(0).
I’ve tried SDL_SelectMouse(0) before and it’s the same.
Julien

I have the same problem under Vista, is this code only solution?

use this code :slight_smile:

Code:
static const char HideArrow[] = {
/
width height num_colors chars_per_pixel /
" 32 32 3 1",
/
colors /
“X c #000000”,
". c #ffffff",
" c None",
/
pixels */
" “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” ",
“0,0”
};

//Create cursor on my mask cursor
static SDL_Cursor init_system_cursor(const char image[])
{
int i, row, col;
Uint8 data[4
32];
Uint8 mask[4
32];
int hot_x, hot_y;

i = -1;
for ( row=0; row<32; ++row ) {
for ( col=0; col<32; ++col ) {
if ( col % 8 ) {
data[i] <<= 1;
mask[i] <<= 1;
} else {
++i;
data[i] = mask[i] = 0;
}
switch (image[4+row][col]) {
case ‘X’:
data[i] |= 0x01;
mask[i] |= 0x01;
break;
case ‘.’:
mask[i] |= 0x01;
break;
case ’ ':
break;
}
}
}
sscanf(image[4+row], “%d,%d”, &hot_x, &hot_y);
return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
}

SDL_Cursor *bHidenCursor;


//On application init
// Hide cursor
bHidenCursor=init_system_cursor(HideArrow);
SDL_SetCursor(bHidenCursor);

//On application close
SDL_FreeCursor(bHidenCursor);

hmmm I’m use XP, use this

Code:
SDL_Event evt;
while(SDL_PollEvent(&evt)) {
switch(evt.type) {
case SDL_ACTIVEEVENT:
if(evt.active.state != SDL_APPMOUSEFOCUS) {
if(evt.active.gain == 1) {
SDL_ShowCursor(0);
}
else {
SDL_ShowCursor(1);
}
}
break;
}
}

Code:
SDL_ShowCursor(SDL_DISABLE);

best regards
MandarX------------------------
http://mandarx.xoom.it/index.php?lang=eng

Be careful with that function. At least on Linux and SDL 1.2, if you have
full-screen mode and you turn the cursor on, then it will jump to an
unpredictable location. There was some discussion about that on the list a
year or two ago. The behaviour is actually not a bug, but a feature (with
a rather convoluted explanation), but the conclusion was that it was a bad
feature. However, it has not been fixed.

As a workaround, you should write a little wrapper around
SDL_ShowCursor(), something like this:

void MyShowCursor( int show )
{
int x, y;

SDL_GetMouseState( &x, &y );
SDL_ShowCursor( show ? SDL_ENABLE : SDL_DISABLE );
SDL_WarpMouse( x, y );

}

Zoltan

SDL version: SDL 1.3
OS: OSX
Used : SDL_WINDOW_OPENGL---------------------------------------

You are right.
It is nor right to do actually. [Embarassed]

I saw that hiding/showing cursor is on TODO list in SDL1.3.
But I needed to hide cursor really.

So that temporal solution is just for the people really need to hide cursor right now, and don’t need to have a function disable/enable mouse cursor.

And
I will try to wrap it like you suggested. If I do, I will post it again.

Thank you.

I use OSX. (leopard/snow leopard)

I still have a mouse cursor.
It looks like that original mouse cursor did not hide.

This is temporal solution if your SDL uses cocoa for creating window.

If you really need to hide “cursor” like me.

Go to src/video/cocoa
Modify SDL_cocoawindow.m

I put these lines before return (end of the function).

Code:

int Cocoa_CreateWindow(_THIS, SDL_Window * window)
{

if (window->flags & SDL_WINDOW_FULLSCREEN)
[NSCursor hide];
return 0;
}