getCursorControl()->setVisible dose not work.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
doma
Posts: 6
Joined: Tue Mar 27, 2007 7:24 am

getCursorControl()->setVisible dose not work.

Post 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;
	}
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

No, this is a bug I reported long ago ...
http://irrlicht.sourceforge.net/phpBB2/ ... ht=#129595
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post 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.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post 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.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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!
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post 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..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
playerdark
Posts: 64
Joined: Mon Aug 01, 2005 5:06 am

Post 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.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The cursors is definitely not moved for making it invisible. What makes you think so?
playerdark
Posts: 64
Joined: Mon Aug 01, 2005 5:06 am

Post 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
Post Reply