Leaving CanvasGadget

Linux specific forum
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Leaving CanvasGadget

Post by Lord »

Hello everybody!

I just tried the CanvasGadget and stumbled over this:

Code: Select all

OpenWindow(1, 10, 10, 400,400,"Test")
CanvasGadget(1, 5, 5, 390, 390, #PB_Canvas_ClipMouse | #PB_Canvas_Border)

Repeat
    Event=WaitWindowEvent()
Until Event=#PB_Event_CloseWindow
If I press the left mouse button and move the mouse,
the cursor can leave the CanvasGadget.

I'm on Ubuntu 12.01.1 with PureBasic 5.00_beta2_x86.

On Windows with PureBasic 4.61 x86 and x64 the cursor
is held on the Canvas.

Any hints?
Image
User avatar
Shardik
Addict
Addict
Posts: 2067
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Leaving CanvasGadget

Post by Shardik »

Please take a look into PB's help
PureBasic Help wrote:#PB_Canvas_ClipMouse: Automatically clips the mouse to the gadget area while a mouse button is down.
If you want to capture the mouse cursor without having to keep a button pressed try this code:

Code: Select all

OpenWindow(0, 10, 10, 400, 400, "Cursor is captured! Click button to leave!")
CanvasGadget(0, 5, 5, 390, 390, #PB_Canvas_Border)

SetGadgetAttribute(0, #PB_Canvas_Clip, #True)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
You may leave the CanvasGadget after pressing a mouse button... :wink:
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Leaving CanvasGadget

Post by Lord »

Hi Shardik!
Shardik wrote:Please take a look into PB's help
PureBasic Help wrote:#PB_Canvas_ClipMouse: Automatically clips the mouse to the gadget area while a mouse button is down.
That is, what I want.
But on Linux it doesn't capture the cursor.
Shardik wrote: If you want to capture the mouse cursor without having to keep a button pressed try this code:

Code: Select all

OpenWindow(0, 10, 10, 400, 400, "Cursor is captured! Click button to leave!")
CanvasGadget(0, 5, 5, 390, 390, #PB_Canvas_Border)

SetGadgetAttribute(0, #PB_Canvas_Clip, #True)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
You may leave the CanvasGadget after pressing a mouse button... :wink:
On Linux, this doesn't work either.
And if you try this on Windows, you never can leave
the Canvas.
Image
User avatar
Shardik
Addict
Addict
Posts: 2067
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Leaving CanvasGadget

Post by Shardik »

Lord wrote:On Linux, this doesn't work either.
I have tested your example and my example on Ubuntu 12.04 x64 with PB 4.61 x64 and they both work as described and expected. Tomorrow at work I also will test on an Ubuntu 12.04 x86 system with PB 4.61 and PB 5.00 Beta 2...


Update: I have tested both examples also on Ubuntu 12.04 x86 and they work as expected. Did you run checkinstall.sh on your Ubuntu installation to check if all dependancies are installed? Did you try your examples on Ubuntu running in a virtual machine? This could perhaps explain your problems. All my tests were done with Ubuntu x86 and x64 installations running natively on real hardware...
Lord wrote:And if you try this on Windows, you never can leave the Canvas.
That's correct. Windows and Linux seem to behave differently in this respect.
In Windows you have to change my posted example to

Code: Select all

OpenWindow(0, 10, 10, 400, 400, "Cursor is captured! Click button to leave!")
CanvasGadget(0, 5, 5, 390, 390, #PB_Canvas_Border)

SetGadgetAttribute(0, #PB_Canvas_Clip, #True)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventType() = #PB_EventType_LeftClick
        SetGadgetAttribute(0, #PB_Canvas_Clip, #False)
      EndIf
  EndSelect
ForEver
in order to allow the cursor to leave the CanvasGadget after a left button click whereas in Linux this seems to work without the additional code...
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Leaving CanvasGadget

Post by Lord »

Shardik wrote:
Lord wrote:On Linux, this doesn't work either.
I have tested your example and my example on Ubuntu 12.04 x64 with PB 4.61 x64 and they both work as described and expected. Tomorrow at work I also will test on an Ubuntu 12.04 x86 system with PB 4.61 and PB 5.00 Beta 2...


Update: I have tested both examples also on Ubuntu 12.04 x86 and they work as expected. Did you run checkinstall.sh on your Ubuntu installation to check if all dependancies are installed? Did you try your examples on Ubuntu running in a virtual machine? This could perhaps explain your problems. All my tests were done with Ubuntu x86 and x64 installations running natively on real hardware...
Yes, I did run checkinstall.sh and I came to the same result as Tsuki-Namida
in his posting in the german forum.
I also followed ts-soft's little tutorial "PureBasic unter Ubuntu installieren für Einsteiger".

And yes, I'm running Ubuntu in VMWare. So it can be the VMWare Tools that
causes this behaviour?
Image
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Leaving CanvasGadget

Post by Lord »

Lord wrote:... So it can be the VMWare Tools that causes this behaviour?
This question is still waiting to be answered.

Does anybody have PureBasic 5.00 Beta2 x86 running
in Ubuntu 12.04 x86 in VMWare and can tell me how
the behaviour of the cursor running the code in my
first posting?
If you push the left mouse button on canvas, hold the
button and move the mouse: can the cursor be forced
to leave the canvas?
Image
Post Reply