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.

DarkBASIC Professional Discussion / Need help handling mouse clicks

Author
Message
God of Thunder
18
Years of Service
User Offline
Joined: 17th Dec 2007
Location: Middle of nowhere, Australia
Posted: 23rd Feb 2010 10:25
G'day

I have been trying to code a function to record mouse clicks so for example

click 0 = no click
click 1 = left mouse button down
click 2 = A single left click (left mouse button down then released)
etc

But I'm just completely lost. Here is an exert of the code which is only partly done and just set up for a simple visual resualt for me to see if its working



The problem seems to be that click never reches 2. It starts at 0 like it should then goes to 1 when i press the left mouse btn down ... but then back to zero when i release it.

I have rewritten this handling function so many time now its not funny. Its probably something obvious but i just can't pick it. Was hopin' a fresh set of eyes could help.

Any help would be extremely appreciated.

Thanx in adavance

Only those who have been through Hell can see Heaven.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Feb 2010 11:16 Edited at: 23rd Feb 2010 11:17
Did you declair "click" as a global variable?

Example:


God of Thunder
18
Years of Service
User Offline
Joined: 17th Dec 2007
Location: Middle of nowhere, Australia
Posted: 23rd Feb 2010 11:49
Yeah i have a section for global variabls and click is one of them.

Dont have a clue with this ... realy frustating.

Only those who have been through Hell can see Heaven.
God of Thunder
18
Years of Service
User Offline
Joined: 17th Dec 2007
Location: Middle of nowhere, Australia
Posted: 23rd Feb 2010 11:55
It might help if i post the overall structure of how i use this code. A very abstract overview would be;

//globals
click = 0

do
call input function
loop

// functions
mouseInputfunction()
{
do something with click

read click value to screen
}

I don't know if this helps .. maybe

Only those who have been through Hell can see Heaven.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Feb 2010 11:57
The code I posted works for me the way you described...

The only other possibility is that it's being reset somewhere else. Can you either post your code or search it for other places where it might be set back to zero?

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Feb 2010 12:07
Change:


to:


You don't need to set it to zero at the start (it will have that value unless set otherwise anyway, but you do need to be explicit about making it "global".

God of Thunder
18
Years of Service
User Offline
Joined: 17th Dec 2007
Location: Middle of nowhere, Australia
Posted: 23rd Feb 2010 12:21
Thnak you backslash man.

I realy am a toss.

I forgot to put the GLOBAL keywaord before its definition.

It must have been creating a new var called click and setting it to zero each time the function was called. Man i rewrote the code so many times ... need to up the coffee dosage i think.

Knew it had to be something simple. Works as i expect now. Thanx heaps for takin the time to help me.

Only those who have been through Hell can see Heaven.

Login to post a reply

Server time is: 2026-07-27 16:01:01
Your offset time is: 2026-07-27 16:01:01