[Closed] Problem making a joystick
Hi. I´m trying to make a joystick. The problem is that when I move the mouse, the checkbutton don´t update the position until the mouse is out the button.
Thanks and sorry for my english.
Hello Aritz 8):
It’s strange that mousemove clausule doesn’t work inside a checkbutton(pickbutton or similar). Your only chance is to offset the mouse outside the button a little bit(or maybe Bobo has an smart alternative :)). But then you can’t deactivate it unless you focus the button with tab and press enter. Anyways, something like this:
-- JOYSTICK
-- by Aritz Aizpurua
-- www.AritzArt.com
macroScript joystick_rollout
category:"AritzTools" buttonText:"Joystick"
toolTip:"Joystick"
(
balioa = [0,0]
rollout joystick_rollout "" width:162 height:162
(
checkbutton jsButton "" pos:[72,72] width:16 height:16
on joystick_rollout mousemove balioa do
(
if jsButton.checked do
(
jsButton.pos=balioa + [-8,8]
)
)
)
createDialog joystick_rollout style:#(#style_titlebar,#Style_toolwindow,#style_sysmenu)
)
Epa Borja. I have tried the same solution but the result is a little dirty. But now I´m going to try other solution. Thanks.:buttrock:
Another solution:
macroScript JOYSTICK
category:"AritzTools" buttonText:"Joystick"
toolTip:"Joystick"
(
balioa = [0,0]
jscenter = [81,81]
jsactive = False
rollout joystick_rollout "" width:162 height:162
(
button btn0 "" pos:[jscenter.x-9,jscenter.y-9] width:17 height:17
button btn1 "" pos:[jscenter.x-5,jscenter.y-18] width:9 height:9 enabled:false
button btn2 "" pos:[jscenter.x+8,jscenter.y-5] width:9 height:9 enabled:false
button btn3 "" pos:[jscenter.x-5,jscenter.y+8] width:9 height:9 enabled:false
button btn4 "" pos:[jscenter.x-18,jscenter.y-5] width:9 height:9 enabled:false
on btn0 pressed do
(
jsactive = True
btn0.pos = [180,180]
)
on joystick_rollout lbuttondown balioa do
(
jsactive = False
btn0.pos = [jscenter.x-9,jscenter.y-9]
)
on joystick_rollout mousemove balioa do
(
if jsactive == True do
(
jscenter = balioa
btn0.pos = [180,180]
btn1.pos = [jscenter.x-5,jscenter.y-18]
btn2.pos = [jscenter.x+8,jscenter.y-5]
btn3.pos = [jscenter.x-5,jscenter.y+8]
btn4.pos = [jscenter.x-18,jscenter.y-5]
)
)
)
createDialog joystick_rollout style:#(#style_titlebar,#Style_toolwindow,#style_sysmenu)
)
Something better :D:
macroScript JOYSTICK
category:"AritzTools" buttonText:"Joystick"
toolTip:"Joystick"
(
balioa = [0,0]
jscenter = [81,81]
jsactive = False
rollout joystick_rollout "" width:162 height:162
(
button btn1 "" pos:[jscenter.x-7,jscenter.y-7] width:15 height:1 enabled:false
button btn2 "" pos:[jscenter.x+7,jscenter.y-7] width:1 height:15 enabled:false
button btn3 "" pos:[jscenter.x-7,jscenter.y+7] width:15 height:1 enabled:false
button btn4 "" pos:[jscenter.x-7,jscenter.y-7] width:1 height:15 enabled:false
button btn0 "" pos:[jscenter.x-7,jscenter.y-7] width:15 height:15
on btn0 pressed do
(
jsactive = True
btn0.pos = [180,180]
)
on joystick_rollout lbuttondown balioa do
(
jsactive = False
btn0.pos = [jscenter.x-7,jscenter.y-7]
)
on joystick_rollout mousemove balioa do
(
if jsactive == True do
(
jscenter = balioa
btn0.pos = [180,180]
btn1.pos = [jscenter.x-7,jscenter.y-7]
btn2.pos = [jscenter.x+7,jscenter.y-7]
btn3.pos = [jscenter.x-7,jscenter.y+7]
btn4.pos = [jscenter.x-7,jscenter.y-7]
)
)
)
createDialog joystick_rollout style:#(#style_titlebar,#Style_toolwindow,#style_sysmenu)
)
One more. Tell me if you like it
macroScript joystick_rollout
category:"AritzTools" buttonText:"Joystick"
toolTip:"Joystick"
(
checked = false
deactivated=(bitmap 16 16 color:blue)
activated=(bitmap 16 16 color:red)
rollout joystick_rollout "" width:162 height:162
(
bitmap BitmapImage "" pos:[73,93] width:16 height:16 bitmap:deactivated
on joystick_rollout lbuttondown balioa do
(
--Clicked inside the bitmap button ?
if( balioa.x<=(BitmapImage.pos.x+16) and
balioa.x>=BitmapImage.pos.x and
balioa.y<=(BitmapImage.pos.y+16) and
balioa.y>=BitmapImage.pos.y
) then
(
checked=not checked
if(checked==true) then
(
BitmapImage.bitmap=activated
)
else
(
BitmapImage.bitmap=deactivated
)
)
)
on joystick_rollout mouseMove balioa do
(
if checked do
(
BitmapImage.pos=balioa + [-8,-8]
)
)
) createDialog joystick_rollout
)
That´s cool! :applause:. even whe can make better looking sliders too.
Now it needs some tweaks to be perfect.
- Limit button movement in the borders. Adjusting the button borders to the window.
- When you click the butoon, it takes the mouse position as center, but it would be greater, that the button saves the relative position with the mouse.
- Click and drag method.
- xy value visualizer.
1 2 3 and 3 are possible. Is not possible from what I know to make bitmap buttons without border. You can use imagetag(that have no borders an some great events to handle them) but the same problem of mousemove arise. Maybe there are some ActiveX controllers to do this. By the way, what do you wan’t to do with this new “controllers”?