This code has been declared by its author to be Public Domain code.
Download source code | mouse buttons onscreen by Mainsworthy | 2011 |
| |
|
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 |
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 |
the release loop is essential for screen buttons
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.
|
|
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.
|
|
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: http://www.thewargamer.com/grognard/godofwars.zip
so if it works it works is my moto :)
|
|
try my Code archives/File Utilities/encrytion text readerwriter for an example source code
|
|
also I dont program graphic intensive programs , I program wargames in 2D, so all works fine for me
|
|
alsi Ive not seen anybody do the sort of wargames I do, so Im alone in methods
|
|
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 :)
|
|
...since stanrol invaded the archives.
Hahaha! LMAO. No doubt.
|
|
stanrol was just a naive enthusiast :P
|
|
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.
|
|
Stanrol is alive and here. I know his new real nickname.
by the way.. it is _realy_ not me!
|
Code Archives Forum