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.

Dark GDK / Why does Dark GDK detect a nonexistant mouseclick?

Author
Message
Pi314159266
User Deleted
Posted: 30th Jul 2009 00:41
My program, like any other, requires the user to click things. Unfortunately, whenever I run my game, somehow Dark GDK assumes that a mouse button has been clicked, and then it calls all of the mouseclick functions. This has gotten very frustrating and I can't figure out what the problem is. Here's what my code looks like:

if (dbMouseClick() == 1)
{
functionA();
functionB();
}

If anyone can find something wrong with this, then any help is appreciated.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 30th Jul 2009 02:40
Are you aware that dbMouseClick() will return results as long as you hold the button down? So even if you click really fast you may poll again before you release the button and get a second hit. You need to use a boolean flag to show that the mouse has been clicked and use that to ignore any subsequent clicks until the mouse is no longer showing clicked then set the flag to false.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 30th Jul 2009 10:31
best way to fix it? I'd say set a variable that's false when the mouse is 0, and when the mouse is clicked, check also that its false, and make it true in the loop.

bloodmage2
15
Years of Service
User Offline
Joined: 14th Jun 2009
Location:
Posted: 2nd Aug 2009 20:17
well, my personal favorite to solve this problem is:


run the function at the start of you while ( LoopGDK ( ) ), and instead of calling dbMouseClick == x, check currentclick == x. works fine for me.

-to the optimist, the glass is half full. to the pessimist, it is half empty, to the engineer, it is twice as big as it needs to be.
Pi314159266
User Deleted
Posted: 5th Aug 2009 04:05
Thanks for the help, and I will definitely use a bool variable to stop dbMouseClick() from returning 1 after the mouse has been clicked once. Still, my problem is that when I start my program, even if I don't touch the mouse at all, dbMouseClick() still returns 1. To me this seems very strange. Any ideas?

Login to post a reply

Server time is: 2024-10-01 08:44:33
Your offset time is: 2024-10-01 08:44:33