[bmx] mouse buttons onscreen by Mainsworthy [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:39

Previous topic - Next topic

BlitzBot

Title : mouse buttons onscreen
Author : Mainsworthy
Posted : 1+ years ago

Description : this code snippet checks current mouse location is within a screen location such as a button, then checks for mouse click, then waits for mouse release! the release loop is essential for screen buttons

Code :
Code (blitzmax) Select
If MouseDown(1) And MouseX() > 957 And MouseX() < 957+45 And MouseY() > 705 And MouseY() < 735
#qwbnms
If MouseDown(1) Then Goto qwbnms
'execute mymousemovedfunction()
EndIf

' if mouse is pressed within screen button region do function, BUT wait until mouse released!


Comments :


matibee(Posted 1+ years ago)

 <div class="quote"> the release loop is essential for screen buttons </div>Sorry buddy but that's just wrong - nobody wants an app to freeze while a mouse button is down.  The correct behavior is to log the button the mouse is pressed down on, then when it's released check if it's still on the same button before firing an event.  If it's moved off, the click doesn't happen.  This is how Windows works, try it.


GfK(Posted 1+ years ago)

 Tell me this is a late April Fool?To be blunt, this is probably the most badly-written code I've seen since stanrol invaded the archives.1. Its not even in a function.2. You've used hard-coded coords for the button boundaries.3. You've used an evil GoTo where a While/Wend or Repeat/Until would have done.Bad bad bad.


Mainsworthy(Posted 1+ years ago)

 GOTO is a very old skool argument, I grew up on zx81 & spectrums BASIC so GOTO is valid for me :) and I believe they would not put it in BASIC if you shouldnt use it :) I know you are talking current tech but Im too old to change.I know its not best code, but Ive done some good programs to justify it eg:<a href="http://www.thewargamer.com/grognard/godofwars.zip" target="_blank">http://www.thewargamer.com/grognard/godofwars.zip</a>so if it works it works is my moto :)


Mainsworthy(Posted 1+ years ago)

 try my Code archives/File Utilities/encrytion text readerwriter for an example source code


Mainsworthy(Posted 1+ years ago)

 also I dont program graphic intensive programs , I program wargames in 2D, so all works fine for me


Mainsworthy(Posted 1+ years ago)

 alsi Ive not seen anybody do the sort of wargames I do, so Im alone in methods


Mainsworthy(Posted 1+ years ago)

 also chess GUI programed with my methods example<a href="http://wbec-ridderkerk.nl/html/details1/Mainsworthy.html" target="_blank">http://wbec-ridderkerk.nl/html/details1/Mainsworthy.html</a>who is to say one method is better than another ,? variety is how to learn


Mainsworthy(Posted 1+ years ago)

 <a href="http://battlegroundsgames.com/forums/index.php" target="_blank">http://battlegroundsgames.com/forums/index.php</a> then goto 'Links & Resources' then the thred 'gameing toolz (windows) new update' and download warbox for another example of my Methods


Mainsworthy(Posted 1+ years ago)

 you are correct matibee, but Im too old to do things text book, may be My code snippet should not have been posted, I was just dropping in a key piece of code that I use, I just fixed as I went along but its alot better your way :)


GfK(Posted 1+ years ago)

 [edit] button?


Rob the Great(Posted 1+ years ago)

 <div class="quote"> ...since stanrol invaded the archives. </div>Hahaha! LMAO. No doubt.


Andres(Posted 1+ years ago)

 stanrol was just a naive enthusiast :P


Rob the Great(Posted 1+ years ago)

 Yeah, I didn't mind his programming. What drove me nuts was how he loved to resurrect posts that were 5+ years old. And a lot of times, it had nothing to do with the topic. He just wanted to promote something he accomplished, and he would pick old topics to do so. I guess it worked, as it got everyone's attention.


ShadowTurtle(Posted 1+ years ago)

 Stanrol is alive and here. I know his new real nickname. by the way.. it is _realy_ not me!