Code archives/User Input/mouse buttons onscreen

This code has been declared by its author to be Public Domain code.

Download source code

mouse buttons onscreen by Mainsworthy2011
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

matibee2011
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.


GfK2011
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.


Mainsworthy2011
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 :)


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


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


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


Mainsworthy2011
also chess GUI programed with my methods example


http://wbec-ridderkerk.nl/html/details1/Mainsworthy.html

who is to say one method is better than another ,? variety is how to learn


Mainsworthy2011
http://battlegroundsgames.com/forums/index.php then goto 'Links & Resources' then the thred 'gameing toolz (windows) new update' and download warbox for another example of my Methods


Mainsworthy2011
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 :)


GfK2011
[edit] button?


Rob the Great2011
...since stanrol invaded the archives.

Hahaha! LMAO. No doubt.


Andres2011
stanrol was just a naive enthusiast :P


Rob the Great2011
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.


ShadowTurtle2011
Stanrol is alive and here. I know his new real nickname.

by the way.. it is _realy_ not me!


Code Archives Forum