Jump to content

[SOLVED] MouseFocus lost


photo

Recommended Posts

Hello Unigine,

in attachment an example with the error - login.rar.

The problem is, if I click into the TEXTBOXES like "Username" or "Password" the mouse focus isn't get lost.post-248-0-72181400-1365022748_thumb.png

Here you see the mouse is visible and the textbox is highlighted.

If I click anywhere else (e.g. into the image) the mouse is hidden, the focus is removed of the username or password field and the mouse is getting hidden.post-248-0-28065400-1365022772_thumb.png

Here you see the mouse isn't visible and the textbox isn't highlighted.

 

I just can bring up the mouse anew if I press "ESC".

 

The problem with .setPermanentFocus is that in Linux are occuring problems then -> Why ever.

 

Furthermore: If I laydown a "GUI_LOST_FOCUS" event and re run the widget.setFocus() function the focus isn't set at all anymore.

 

PS: ui.updateWidts, widget.arrange() don't help in this case.

 

Please have a look.

A fast solution would be good, we don't have that much time any more left.

 

Best regards

Lars

login.rar

Link to comment

Hi Lars,

 

You can use define MOUSE_SOFT to avoid such issues. Implementation of this feature you can find in our Heaven Benchmark.

Please, take a look at the <SDK>/data/demos/heaven/unigine.cpp file at line 22. We are using in release builds #define MOUSE_SOFT which is allows not to lost focus while clicking on non-UI elements (should work perfectly in your case). Code for this define is located in <SDK>/data/core/scripts/system/system.h at line 374.

 

Modified example in attach. I'll sent the suggestion about lost focus on Widget click to the developers, but I can't tell you any ETA when this feature will be implemented.

login.zip

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

After finally 4 hours...:

 


 if ((mode!= login&& mode != playing))
 {
 if(engine.gui.getMouseButton() == APP_BUTTON_LEFT && engine.gui.getActivity() == 0) {
 engine.controls.setMouseEnabled(1);
 } else {
 engine.controls.setMouseEnabled(0);
 }
 }
 else if (mode == login)
 {
 engine.gui.setMouseCursor(GUI_CURSOR_NONE);
 engine.app.setMouseShow(1);
 // engine controls
 if(engine.gui.getMouseButton() == APP_BUTTON_LEFT && engine.gui.getActivity() == 0) {
 engine.controls.setMouseEnabled(1);
 } else {
 engine.controls.setMouseEnabled(0);
 }
 }

 

Its such a realy strange behaviour and interaction of settings.

Sometimes my mouse was "catched" in mid and couldn't get the mouse of the frame, just if I pressed ESC.

The problem is now. the starting mouse is black, the setted mouse if we're going to login is WHITE.

I'll try via weekend to provide a possibility that a click event on a widget which is rendered into the world not focuses the world, but if the cursor clicks into world the world is getting focused.

Greetings & Good Night

Lars

Link to comment

After about 13 hours of trying, I found a solution to work now.

 

@Silent: Your implementation "worked" but I don't realy want to see a flickering mouse - I mean - where is the user experience?

 

If someone needs tips / code example write me.

Greetings

Lars

Link to comment

After about 13 hours of trying, I found a solution to work now. If someone needs tips / code example write me.the

 

Why not simply sharing the solution approach here on the forum ? Forum means taking and giving ;)

Link to comment

Hi Ulf,

 

cause its very project specific and I don't get how its working at all, but I can share it like I wrote:

 

 

If someone needs tips / code example write me.

I'll share the solution later.

Link to comment
int waitCall =0;
function update()
{
               if ((mode != login&& mode != playing))
               {

                    if(engine.gui.getMouseButton() == APP_BUTTON_LEFT && engine.gui.getActivity() == 0) {
                        engine.controls.setMouseEnabled(1);
                    } else {
                        engine.controls.setMouseEnabled(0);
                    }

                }
               else if (mode == login)
               {
                   engine.gui.setMouseCursor(GUI_CURSOR_NONE);
                   engine.app.setMouseShow(1);

                   if(engine.gui.getMouseButton() == APP_BUTTON_LEFT && engine.gui.getActivity() == 0) {
                       engine.controls.setMouseEnabled(1);
                   } else {
                       engine.controls.setMouseEnabled(0);
                   }

               }
               else if (mode == playing)
               {
                   if (isChatWindowOpen() == 1 || isESCMenuOpen() == 1)
                   {


                       Widget opendWidget = getOpendMenu();
                       int minPosX = opendWidget.getPositionX();
                       int maxPosX = opendWidget.getPositionX() + opendWidget.getWidth();
                       int minPosY = opendWidget.getPositionY();
                       int maxPosY = opendWidget.getPositionY() + opendWidget.getHeight();


                       int posMouseX = engine.app.getMouseX();
                       int posMouseY = engine.app.getMouseY();
                       if (engine.gui.isMouseEnabled())
                       {
                           waitCall = 0;
                       }

                       if ((posMouseX >= minPosX) && (posMouseX <=maxPosX) && (posMouseY >= minPosY) && (posMouseY <= maxPosY) && waitCall == 0)
                       {
                            engine.gui.setMouseCursor(GUI_CURSOR_NONE);
                            engine.app.setMouseShow(1);
                            if(engine.gui.getMouseButton() == APP_BUTTON_LEFT && engine.gui.getActivity() == 0) {
                                engine.controls.setMouseEnabled(1);
                            } else {
                                engine.controls.setMouseEnabled(0);
                            }

                       }
                       else
                       {

                           if (waitCall==0)
                           {
                               engine.gui.setMouseCursor(1);
                               if(engine.gui.getMouseButton() == APP_BUTTON_LEFT && engine.gui.getActivity() == 0) {
                                 waitCall =1;
                               }
                           }
                           else
                           {
                               engine.app.setMouseShow(0);
                           }

                       }
                   }
                   else
                   {
                       if (engine.gui.getMouseCursor()!= 1)
                       {
                            engine.gui.setMouseCursor(1);
                       }

                   }
               }
else
 {

 if (getHideMouse() == 1)
 {
 engine.gui.setMouseCursor(GUI_CURSOR_NONE);
 engine.controls.setMouseEnabled(1);
 engine.app.setMouseGrab(1);
 ROAClient::hideMouseCall(0);

 }

 //Just hide mouse if mouse is grabbed.
 if(engine.app.getMouseGrab() == 1)
 {
 engine.gui.setMouseCursor(GUI_CURSOR_NONE);
 }



 }

}

 

So here's the solution, I don't know how exactly its working together, the code above is fitted for our project.

 

The main problem is when the Widget is located in mid cause we're checking the mouse cords, and if the mouse is hidden, unigine paste the mouse into "mid".

Have fun with trying out.

 

Edit 1: Inserted last else state, if a widget was brought up and the widget was closed, the mouse needed to focus the world anew. 

-> if(engine.app.getMouseGrab() == 1)


 {
 engine.gui.setMouseCursor(GUI_CURSOR_NONE);
 }Cause the mouse is always triggered to be shown we need to check if the getMouseGrab is available.Else the ESC Event cant never be triggered again.

Edit 2: If you don't wanna have mouse flickering and mouse changing remove:

engine.gui.setMouseCursor(GUI_CURSOR_NONE);
engine.app.setMouseShow(1);

 

 

 

 

Greetings

Lars

Link to comment
×
×
  • Create New...