Page 1 of 1
Leaving CanvasGadget
Posted: Tue Sep 11, 2012 3:47 pm
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?
Re: Leaving CanvasGadget
Posted: Tue Sep 11, 2012 6:18 pm
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...

Re: Leaving CanvasGadget
Posted: Tue Sep 11, 2012 7:21 pm
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...

On Linux, this doesn't work either.
And if you try this on Windows, you never can leave
the Canvas.
Re: Leaving CanvasGadget
Posted: Tue Sep 11, 2012 8:42 pm
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...
Re: Leaving CanvasGadget
Posted: Wed Sep 12, 2012 8:29 am
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?
Re: Leaving CanvasGadget
Posted: Fri Sep 14, 2012 3:35 pm
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?