Page 1 of 1

Stop mouseUp response

Posted: Thu Jan 26, 2017 4:29 pm
by starfirescully
Hello all.

I am experiencing an issue with part of the program I have created.
This program displays 4 faces randomly one at a time 30 times each. In between the presentation of each face, participants are asked to press a button to indicate the first letter of the name belonging to the face. Here is the code for each of the buttons:

THIS IS THE CODE FOR THE LETTER BUTTONS

Code: Select all

global gToggle
on mouseUp
   if gToggle is 1 then #this code is to turn on the button
      send mouseup to button "ShowFace" #this sends the command to show the face
   else 
      pass mouseUp
   end if
end mouseUp

on mouseDoubleUp
# do nothing
end mouseDoubleUp


HERE IS THE ISSUE: During the presentation of the face, if the participant clicks where the buttons will appear, the program does not stop to let them to choose a button. It acts as if the button was selected and skips to the next face.

I have tried disabling the buttons, hiding the buttons, and creating a toggle in between the presentation of the button.

THIS IS THE CODE FOR THE SHOW FACES BUTTON

Code: Select all

global gToggle
on mouseUp    
   put 2 into gToggle
   set the cursor to none
   hide button "ShowFace"

#these are the letter buttons
   hide button "A"
   hide button "W"
   hide button "J"
   hide button "D"
   
   disable button "W" 
   disable button "J" 
   disable button "D" 
   disable button "A" 

###this is where the display picture code is, leaving out for simplicity###
end mouseUp

In sum,

The program:

Displays a Face
then
Displays four Buttons (W,J,D, and A)
When clicking one of those buttons the program advances to the next face.

While the face is displayed, if the participant clicks in the area where the buttons are, the mouseUp responses is saved until the buttons appear, and then the program automatically advances to the next face.


----I have also tried putting an invisible button in the way of the other buttons. This does not work.-----


Thank you!

Re: Stop mouseUp response

Posted: Thu Jan 26, 2017 7:10 pm
by jmburnod
Hi,
I don't understand when you set global gToggle to 1
Jean-Marc

Re: Stop mouseUp response

Posted: Thu Jan 26, 2017 8:34 pm
by starfirescully
I was trying to toggle the buttons on and off so that the error wouldn't occur.

Re: Stop mouseUp response

Posted: Thu Jan 26, 2017 10:52 pm
by jmburnod
Hi starfirescully ,
I'm not sure what you want, but You can use a timer to avoid click before n milliseconds.
You may have a look at flushevents in LC dictionary
Something like that:

Code: Select all

local sStarTime
on opencard
      put the milliseconds into sStarTime 
end opencard

on mouseUp
   put the milliseconds into tTime
   if tTime > sStarTime +500 then
      beep
   else
      --
   end if
   put the milliseconds into sStarTime
end mouseUp
Best regards
Jean-Marc

Re: Stop mouseUp response

Posted: Fri Jan 27, 2017 7:45 pm
by jacque
I think jmburnod was asking where the scripts set the global variable to 1.

Comment out the "pass mouseUp" and see if that helps.

The enabled state of the button, or having it covered by another object, won't stop commands that are sent directly to the object's script. Those properties only block manual actions.

Re: Stop mouseUp response

Posted: Mon Jan 30, 2017 8:24 pm
by starfirescully
I tried to put the buttons on a different card and I am still experiencing an issue.

Here is the new code:

Card 1
This card shows the face

In card script

Code: Select all

on opencard
send mouseUp to button "button"
end opencard
In Button "button"

Code: Select all

on mouseUp    
   set the cursor to none
   show image "displaypictures"
   put empty into image "displaypictures"

###then there is code to show the image###

go to next card
   
end mouseUp

Card 2
This card shows the button group

Code: Select all

on mouseUp
      put "," & the label of  target after alltogether
      wait 1 second
      hide group "buttongroup"
      hide fld "question"
      wait 1 second
      go to previous card
end mouseUp
      
Again, the issue is if I click where the buttons will show up on Card 2, it will automatically send the mouseUp command to the button group when it shows up.

Re: Stop mouseUp response

Posted: Mon Jan 30, 2017 8:32 pm
by starfirescully
jacque wrote:I think jmburnod was asking where the scripts set the global variable to 1.

Comment out the "pass mouseUp" and see if that helps.

The enabled state of the button, or having it covered by another object, won't stop commands that are sent directly to the object's script. Those properties only block manual actions.

I decided to try a different route other then the gToggle.
Commenting out pass mouseUp did not work either.

My previous posts outlines how I tried to fix the issue. It still does not work

Re: Stop mouseUp response

Posted: Mon Jan 30, 2017 8:58 pm
by starfirescully
jmburnod wrote:Hi starfirescully ,
I'm not sure what you want, but You can use a timer to avoid click before n milliseconds.
You may have a look at flushevents in LC dictionary
Something like that:

Code: Select all

local sStarTime
on opencard
      put the milliseconds into sStarTime 
end opencard

on mouseUp
   put the milliseconds into tTime
   if tTime > sStarTime +500 then
      beep
   else
      --
   end if
   put the milliseconds into sStarTime
end mouseUp
Best regards
Jean-Marc
Jean-Marc

Using a timer would not be useful for the presentation of the buttons and faces. I tired to use flusheventts

Code: Select all

put flushEvents("mouseUp") into temp
in each button and this only worked partially

Re: Stop mouseUp response

Posted: Mon Jan 30, 2017 9:05 pm
by starfirescully
starfirescully wrote:I tried to put the buttons on a different card and I am still experiencing an issue.

Here is the new code:

Card 1
This card shows the face

In card script

Code: Select all

on opencard
send mouseUp to button "button"
[b]put flushEvents("mouseUp") into temp[/b]
end opencard
In Button "button"

Code: Select all

on mouseUp    
   set the cursor to none
[b]put flushEvents("mouseUp") into temp[/b]
   show image "displaypictures"
   put empty into image "displaypictures"

###then there is code to show the image###

go to next card
   
end mouseUp

Card 2
This card shows the button group

Code: Select all

on mouseUp
      [b]put flushEvents("mouseUp") into temp[/b]
put "," & the label of  target after alltogether
      wait 1 second
      hide group "buttongroup"
      hide fld "question"
      wait 1 second
      go to previous card
end mouseUp
      
Again, the issue is if I click where the buttons will show up on Card 2, it will automatically send the mouseUp command to the button group when it shows up.

As you can see in the above code, I add flushevents. This works initally. However when the user chooses a button, the program now sends the mouseup automatically to the previous button, not the one that the user clicked in the group.

Re: Stop mouseUp response

Posted: Tue Jan 31, 2017 12:13 am
by starfirescully
starfirescully wrote:
starfirescully wrote:I tried to put the buttons on a different card and I am still experiencing an issue.

Here is the new code:

Card 1
This card shows the face

In card script

Code: Select all

on opencard
send mouseUp to button "button"
[b]put flushEvents("mouseUp") into temp[/b]
end opencard
In Button "button"

Code: Select all

on mouseUp    
   set the cursor to none
[b]put flushEvents("mouseUp") into temp[/b]
   show image "displaypictures"
   put empty into image "displaypictures"

###then there is code to show the image###

go to next card
   
end mouseUp

Card 2
This card shows the button group

Code: Select all

on mouseUp
      [b]put flushEvents("mouseUp") into temp[/b]
put "," & the label of  target after alltogether
      wait 1 second
      hide group "buttongroup"
      hide fld "question"
      wait 1 second
      go to previous card
end mouseUp
      
Again, the issue is if I click where the buttons will show up on Card 2, it will automatically send the mouseUp command to the button group when it shows up.

As you can see in the above code, I add flushevents. This works initally. However when the user chooses a button, the program now sends the mouseup automatically to the previous button, not the one that the user clicked in the group.
I figured out the soultion! Within the button on Card 1, during my wait message if I also add

Code: Select all

wait 2 seconds with messages
It works!

Thanks for all of your help!