Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Mouse Release not working

Author
Message
HeavyAmp
18
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 4th Dec 2006 02:36
I cant Figure out why this isn't working. It should detect if you have lifted the left mouse button. It seems fine to me

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 4th Dec 2006 03:54
It probably doesn't work because the function is so fast... you need many loops to detect it properly. It's probably best to keep mouse button detection outside of a function.



You can also just stop all action till the mouse button is let go.


HeavyAmp
18
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 4th Dec 2006 05:08
Thanks for the help Grog. I can see what you mean, It detects that the mouse has been been lifted but by the time that information has reached my button code it has already been updated to not lifted.

Your examples don't help my situation much because the first one only detects if the mouse button is pressed or not pressed. What I am after is the actual action of the button from pressed to not pressed but I need to get this information to the parts of my code that need it before it switches back to has not been lifted. The second example could work for certain cases but i need to update other parts of the program while still detecting if it has been lifted or not.

Ive just come up with a possible idea on how to solve this while writing this post but it may not be practical. Maybe I could have have it store whether it has been lifted for a certain amount of time and after that time reset it to has not been lifted. Enough time for the rest of the program to use the lifted variable. 0.25 seconds or something. Is there any other way to do this or an easier way?
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Dec 2006 08:46
You should store the last state of the mouse, like call it LastMouseClick, but globalise it:

Global MX
Global MY
Global MouseClick
Global LastMouseClick
Global MouseState `(0=nothing, 1=clicked, 2=unclicked


Function update_mouse()
MX=mousex()
MY=mousey()
LastMouseClick=MouseClick
MouseClick=mouseclick()
if MouseClick=0 and LastMouseClick=0 then MouseState=0
if MouseClick>0 and LastMouseClick=0 then MouseState=1
if MouseClick=0 and LastMouseClick>0 then MouseState=2
Endfunction

''Stick that in your text and scroll it!.''
HeavyAmp
18
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 4th Dec 2006 14:39 Edited at: 4th Dec 2006 15:57
Quote: "
You should store the last state of the mouse, like call it LastMouseClick, but globalise it
"


Thats defiantly an easier way of doing it compared to the way I thought of. Thanks for both your help VanB and Grog its much appreciated.

Edit:
I tested the code out it works fine but I'm still left with a bit of a problem. I have a Screen with a button On it and when you press it it goes to another screen. Theres another button on the second screen in the same place as the first button. And this button goes to a third screen. When I click too fast on it it completely misses the Second screen and jumps right to the third.

Edit: Ahh never mind i figured it out When the mouse button has detected that it has been pressed I just change the MouseState to 0
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 4th Dec 2006 20:00 Edited at: 4th Dec 2006 20:00
Np. With menus that are over menus I use a timer that starts the moment the menu is changed... the timer has to go beyond a set time before it allows another menu selection... usually 100 milliseconds is plenty of a delay.

Sometimes I just use this (but I really don't like forcing the user to click their mouse a specific way):
HeavyAmp
18
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 4th Dec 2006 21:17
I need to write these ideas down somewhere or better yet remember them
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Dec 2006 01:52
They'll be here till the end of time... in 2012.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 5th Dec 2006 04:05
That is not- I promise you- the end of time.

In many religions, 40 years before the world ends, Jesus Christ, and his Anti, will be reincarnated upon this earth. And with him he will bring lots of chaos and rebellion.

I don't see any of it.


But since this is getting religious, we could take it to MSN. I love sharing theories

-Mansoor Siddiquie

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Dec 2006 08:10
Actually the Anti-Christ is born on Earth and Jesus comes from Heaven... neither of which are reincarnated. The chaos starts when millions of people suddenly disappear. "Ack! The aliens took em!"

It's not me it's the Mayans. They thought a significant event would happen in 2012. Significant enough to be "the end of the world as we know it". I think we should end the debate right now though (well after you reply). Today I tried to post a lengthy message about "aliens" but the thread was locked before I posted.

The bit about 2012 is close to the bottom:
http://en.wikipedia.org/wiki/Maya_calendar
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 5th Dec 2006 08:31
my mate has a band called 2012, and i did learn about the end of the world with regards to the mayan calender.
but yeah no religion stuffz here plz.

HeavyAmp
18
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 8th Dec 2006 20:59
Would make for a good game story

Login to post a reply

Server time is: 2024-11-26 05:55:03
Your offset time is: 2024-11-26 05:55:03