Preventing mouse click

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Casey Morgan
Posts: 9
Joined: Sat Jan 24, 2015 5:30 pm

Preventing mouse click

Post by Casey Morgan » Sat Mar 14, 2015 3:45 pm

I am working on a customized app for a child with cerebral palsy. He isn’t able to use his hands, so the button choices are scanned and he will press a switch when his choice is highlighted. Everything works well until the touchscreen is tapped during the button scan. Since he will have caregivers setting up the equipment, this is an issue. The mouse message is sent and the scanning feedback (sound file to play a click) gets out of synch with the scanning. I have tried to trap the clicks using exit mouse up/down, but it is not helping. I would appreciate any suggestions.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Preventing mouse click

Post by dunbarx » Sat Mar 14, 2015 4:19 pm

Hi.

Is this on mobile? I work with external I/O devices connected to a computer. How is this "switch" connected?

I am not understanding. You have started a process where, say, the hlites of a series of buttons are sequentially set to "true" at a set rate"? And when a particular one is hilited, a switch is pressed to identify that one as the desired one?

When the external button is pressed, how is this translated into a "mouseUp" message being sent to the LC app? Whatever the answers to these questions, the solution to your problem is certain to be manageable and simple to implement.

Why is it possible for the child to press a switch, but not possible to press the mouse, or tap the screen if mobile?

Craig Newman

Casey Morgan
Posts: 9
Joined: Sat Jan 24, 2015 5:30 pm

Re: Preventing mouse click

Post by Casey Morgan » Sat Mar 14, 2015 5:22 pm

A USB switch it attached to the computer and configured to send a mouse click when pressed. The switch is a Switch Click USB from AbleNet. He presses the switch using his head. The computer is an "open" augmentative communication device (ECO2 by PRC) which means that it has a touchscreen. I can set a touch delay on the screen, but caregivers use it instead of a mouse. His siblings also use the touchscreen to navigate youtube ect with him. I don't want to take that away. It's like a tablet computer attached to a wheelchair by a mount. I tried to post links but my account does not have permission.

I have grouped buttons as an onscreen keyboard. Starting with button #1, the hilite is set for 1 1/2 seconds. If he doesn't press the switch, the hilite is set to false and button #2 is hilited for 1 1/2 seconds. This continues to all of the buttons in the group. Once he presses the Switch Click, a mouseUp message is sent to the hilighted button. After the script is sent to the card and finished - in this case it shows a vocabulary word and picture - the scanning resumes with button #1. The group of buttons is a background group.

I would like to be able to use this app with other kids who do use a mouse or touchscreen. I have it set up so that the access method can be selected - switch scanning or mouse. The access method is stored as a custom property cSwitch or cMouse. So, I have been trying things like "if the cSwitch of this stack is true then...." I have tried to exit the mouse click and trap it using flushevents. The problem is that the button that is clicked during the scan still gets hilited, which throws off the scanning and the audio file (a beep) that is used to give the child feedback gets out of synch with the scan timing.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Preventing mouse click

Post by FourthWorld » Sat Mar 14, 2015 5:33 pm

The flushEvents function can be helpful in cases like this.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Preventing mouse click

Post by jacque » Sat Mar 14, 2015 7:55 pm

It sounds like you may have autohilite set for the scanned buttons. That would cause the button to hilite when pressed regardless of how the script has set it. Is that the case?

If so, and the script is controlling the hiliting by itself, then you can check to see if the hilite of the manually-clicked button is true and only respond if it is.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Preventing mouse click

Post by dunbarx » Sat Mar 14, 2015 8:19 pm

Hmmm.

Kudos for working on this. I teach programming to a troubled teen. Very challenging and satisfying.

How did you port the app to the computer? Does it run Windows, Mac or Linux apps? What do you develop on?

So you have a sequencer running that selects hilites at intervals, And I assume that messages have been enabled during this process, either by "wait with messages" or via the "send" or "dispatch" commands. When the mouse is clicked, do you mean that an arbitrary button, not on the sequence is hilited? Or some other event is triggered? Try this. Make a button and a field on a new card. In the button script:

Code: Select all

on mouseUp
   if the catchMouse of me = "true" then exit to top
   timeout
end mouseUp

on timeOut
   set the catchMouse of me to "true"
   add 1 to fld 2
   -- do your hilite routine here
   if the optionKey is down then 
      set the catchMouse of me to "false"
      exit to top
   end if
   send "timeOut" to me in 60
end timeOut
If this helps, then all you have to do is perhaps move the whole thing to the card script and tweak. By tweak, I mean that all local mouseUp handlers have to either move to the card script, or test the state of the custom property locally.

Or I am still missing it...

Craig
Last edited by dunbarx on Sun Mar 15, 2015 10:23 pm, edited 1 time in total.

Casey Morgan
Posts: 9
Joined: Sat Jan 24, 2015 5:30 pm

Re: Preventing mouse click

Post by Casey Morgan » Sat Mar 14, 2015 10:49 pm

Jacque - the autohilte is on. I thought of it while running errands today. I think turning that off will help.

Craig - I am not sure what you mean by "port the app." I work with a school based assistive technology team and we have been "playing" with LiveCode Community in order to customize applications for some of our most challenging students. The ECO2 this particular student uses is a Windows XP computer that is the hardware for an augmentative communication devices. It was purchased through a grant, so the computer functions haven't been "locked out" like they are when insurance funds the device.

I think the timeOut handler will do the trick once I turn off the button autohilites. I do have one question - is "catchMouse" a variable? I am not really understanding what it is doing.

Thanks for all of your help.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Preventing mouse click

Post by dunbarx » Sun Mar 15, 2015 12:46 am

hi.

No. "CatchMouse" is the name of a custom property that I made up. It is clear by context what that is. What I mean is that even in the very first line of the mouseUp handler, the code structure implies a custom property, named as such, and its value tested, even though the engine has never heard of it. The engine is not thrown by such a construct, and assumes its value is empty. It is explicitly set in the secondary handler, and from that point on has an explicit value.

Let us know how it goes.

Craig

Casey Morgan
Posts: 9
Joined: Sat Jan 24, 2015 5:30 pm

Re: Preventing mouse click

Post by Casey Morgan » Sun Mar 15, 2015 9:20 pm

I can see it as a custom property now. I have even been using them and the "set" keyword went right pass me. Disabling the autohilite is working to keep the scan sequence working. I am still working on keeping the mouse click from being sent. It will probably be next weekend before I can get to it again, but will definetly update how it is working. Thanks for all of your help.

Casey Morgan
Posts: 9
Joined: Sat Jan 24, 2015 5:30 pm

Re: Preventing mouse click

Post by Casey Morgan » Sun Apr 05, 2015 5:17 pm

This drove me nuts! I finally figured out that the grouped buttons were getting the message before the group control itself. This seems backwards to me. I ended up adding a transparent button with empty mouse handlers over the group whenever a student is scanning. That made it work, and now I don't have to worry about unintended touch activations. Thanks for all of your help.

Post Reply