Page 1 of 2

getCursorControl()->setVisible dose not work.

Posted: Wed Jan 23, 2008 5:44 am
by doma
setVisible does not work.
but debug is ok.
what is wrong?

Code: Select all

if (event.MouseInput.Event < irr::EMIE_MOUSE_MOVED) {
	switch(event.MouseInput.Event) {

		case EMIE_RMOUSE_PRESSED_DOWN:
			device->getCursorControl()->setVisible(false);
			cout<<"down "<<device->getCursorControl()->isVisible()<<endl;
		break;
	
	case EMIE_RMOUSE_LEFT_UP:
		device->getCursorControl()->setVisible(true);
		cout<<"up "<<device->getCursorControl()->isVisible()<<endl;
		break;
	}
}

Posted: Wed Jan 23, 2008 8:30 am
by hybrid
First of all, your if test is wrong. You have to make sure it's a mouseinput before using the elements under that assumption. But the problem is that you will only see the effect when moving your mouse a little bit, otherwise the cursor is not updated.

Posted: Wed Jan 23, 2008 11:12 am
by shogun
No, this is a bug I reported long ago ...
http://irrlicht.sourceforge.net/phpBB2/ ... ht=#129595

Posted: Wed Jan 23, 2008 3:28 pm
by MasterGod
Why really isn't it fixed.. Its known for a very long time..
@doma: Change visibility like this:

Code: Select all

void AClassFromMyProject::setCursorVisible(bool visible) const
{
	ICursorControl* cursor = m_pDevice->getCursorControl();
	cursor->setVisible(visible); // This line and the next should go hand by hand
	cursor->setPosition(cursor->getPosition());
}
This way it updates itself, call it refresh if you like so the visibility is changed without having you moving the mouse right after setVisible() was called.

Posted: Wed Jan 23, 2008 3:38 pm
by greenya
MasterGod wrote:Why really isn't it fixed.. Its known for a very long time..
I guess developers of Irrlicht (which is completely free) know better what to fix and when 8)

p.s.: sorry for offtopic.

Posted: Wed Jan 23, 2008 5:33 pm
by rogerborg
MasterGod wrote:Why really isn't it fixed.. Its known for a very long time..
I don't know why your patch to fix it wasn't accepted. Where would I find it?

Posted: Wed Jan 23, 2008 6:46 pm
by hybrid
It also seems to be a win32 related problem. These are somewhat behind the schedule for some time now, due to lack of people taking care of that Irrlicht device... So it really needs good and documented patches for me to commit them almost untested!

Posted: Wed Jan 23, 2008 6:52 pm
by MasterGod
rogerborg wrote:
MasterGod wrote:Why really isn't it fixed.. Its known for a very long time..
I don't know why your patch to fix it wasn't accepted. Where would I find it?
grrr!! :x You're right again.. :? :wink:

*Note for myself* - Make that patch already you lazy herbivore..

Posted: Fri Jan 16, 2009 3:33 pm
by CuteAlien
I also needed to disable the cursor on windows, so I wrote some patch for that now.

In CIrrDeviceWin32.cpp I removed the stuff in WM_SETCURSOR. I don't know why it was done that way, but I think to make that old code work like expected the cursor of the window-class would have to be removed. Instead I changed setVisible in CIrrDeviceWin32.h to look like that:

Code: Select all

//! Changes the visible state of the mouse cursor.
virtual void setVisible(bool visible)
{
    CURSORINFO info;
    info.cbSize = sizeof(CURSORINFO);

    if ( visible )
    {
        while ( GetCursorInfo(&info) )
        {
            if ( info.flags == CURSOR_SHOWING )
            {
                IsVisible = visible;
                break;
            }
            ShowCursor(true);   // this only increases an internal display counter in windows, so it might have to be called some more
        }
    }
    else
    {
        while ( GetCursorInfo(&info) )
        {
            if ( info.flags == 0 )  // cursor hidden
            {
                IsVisible = visible;
                break;
            }
            ShowCursor(false);   // this only decreases an internal display counter in windows, so it might have to be called some more
        }
    }
}
Seems to work here,but any further testing and feedback from other people is welcome.

Posted: Mon Jan 19, 2009 2:49 pm
by rogerborg
Just a note that I can't replicate the problem using:

trunk, SVN 2097, example 02.Quake3Map, run in windowed mode. The cursor isn't visible when I run it, as expected.

If anyone can replicate the problem that CuteAlien is seeing, on any branch, then please do let us know. Sample code would be ideal.

Posted: Mon Jan 19, 2009 4:42 pm
by CuteAlien
*sigh* I also can't replicate it with current trunk. Which is especially strange as I also tried adding the changes which had been made in the meantime before I started fixing it. Probably I missed something.

Posted: Tue Mar 24, 2009 5:36 am
by playerdark
I just want to add that the bug shows for me. NVIdia 7300 with performance HUD drivers installed. I would not stake my life on it but I am pretty sure that hiding the cursor worked with V1.2 which I was using until last week, same configuration otherwise.

I looked into the code in the device that makes the curser invisible and it seems that this done by using a trick in which the cursor is placed outside the visible windows. This will not work if the code alters the mouse position of course, which is the case for me and probably also for the other user who sees the error. Maybe this helps to reproduce the error.

Altering the mouse position while the cursor is invisible is an important feature. I use it while moving my camera around with the mouse.

Posted: Tue Mar 24, 2009 8:51 am
by CuteAlien
Do you have some test-code to reproduce the problem?
If I boot into Windows some time I'll try altering the mouse position after setting it invisible, maybe that was what I've been missing in my test.

Posted: Tue Mar 24, 2009 8:52 am
by hybrid
The cursors is definitely not moved for making it invisible. What makes you think so?

Posted: Tue Mar 24, 2009 8:30 pm
by playerdark
I thought so due to the updateInternalCursorPosition() call but maybe it does something else. Probably does because I removed the call and still the cursor does not become invisible