IsLeftMouse and StrinRequest possibly bug?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1411
Joined: Sun Feb 14, 2010 7:11 pm

IsLeftMouse and StrinRequest possibly bug?

Post by Bugala »

I am currently trying to isolate the exact problem, but this one seems bit weird one so Im throwing you a question already Andreas in case you happen to have some idea what can cause this.

I am suspecting this problem has to do with usage of stringrequest, but that is just a guess.

In my program, It checks IF left mouse button is pressed with IsLeftMouse(), then it goes through If Statements and does its things.


Strange thing however is, that I have there 3 different IF possibilities, two which have StringRequest functions in them.

If either of those StrinRequest IF places is executed, it seems that program decides that IsLeftMouse() is always TRUE. And that is very weird.

I also tried changing IsLeftMouse() to IsKeyDown("w") and then it worked like it was supposed to, so it clearly is something to do with the IsLeftMouse() thing. I am however not sure if it is a bug, or maybe property.

The program is somewhat big, but to shorten the idea, it is like this:

Code: Select all

leftmousebutton = IsLeftMouse()

If Leftmousebutton = 1
   If tileset=1
      does stuff
   elseif tileset=2
      does stuff plus stringrequests
   elseif tielset=3
     does stuff plus strinrequests
   endif
endif
As i mentioned, when tileset is 1, no problem, it works right, but if tileset is 2 or 3, it keeps repeating it again and again. And the reason why it keeps repeating it again and again is because it for some reason decides that mousebutton=1.

And as i mentioned, If i change this:

Code: Select all

mousebutton = IsLeftMouse()
to 
mousebutton = IsKeyDown("w")
It works fine.


So do you maybe already know what is possibly going on here?

I am trying to isolate the problem to be repeatable by only couple of lines of code, but thought while doing that I ask in case you already know the answer to this one, since right now it seems it could be a bug in the IsLeftMouse() command, and cause could be anything in the program.
jalih
Posts: 281
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: IsLeftMouse and StrinRequest possibly bug?

Post by jalih »

Hello,

I can confirm Bugalas observation, just tested this on Windows version...

Bugala: For now, you can put a ResetKeyStates() call after the requester function call.
Bugala
Posts: 1411
Joined: Sun Feb 14, 2010 7:11 pm

Re: IsLeftMouse and StrinRequest possibly bug?

Post by Bugala »

Thanks a dozen jalih!

Both from giving me solution as well as confirming that trouble, you saved me whole load of time doing that.

But one question, how did you repeat that problem?


For I tried starting my program with following lines:

Code: Select all

waitLeftMouse()
s$ = StringRequest()
temp = IsLeftMouse()
debugprint(temp)
But at least that didnt activate the problem but it showed IsLeftMouse() as False like it was supposed to.
jalih
Posts: 281
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: IsLeftMouse and StrinRequest possibly bug?

Post by jalih »

Bugala wrote:But one question, how did you repeat that problem?
This will do...

Code: Select all

Repeat
	lmbutton = IsLeftMouse()	
	If lmbutton Then s$ = StringRequest("Test", "just type something...")
	lmbutton = False
 	Wait(50)
Forever
Bugala
Posts: 1411
Joined: Sun Feb 14, 2010 7:11 pm

Re: IsLeftMouse and StrinRequest possibly bug?

Post by Bugala »

okay, seems WaitLeftMouse() doesnt do the same, it happens only with IsLeftMouse and StringRequest() in connection.

I to otried with Windows, I wonder if it happens with other platforms too, or if its windows specific problem.
User avatar
airsoftsoftwair
Posts: 5933
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: IsLeftMouse and StrinRequest possibly bug?

Post by airsoftsoftwair »

This is a known problem/bug but there is no easy way to fix it. So the best idea is to do what jalih suggested: Just call ResetKeyStates() and it should be fine.
Post Reply