Activating procedures with multiple buttons

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
k.oneil
Posts: 2
Joined: Mon Feb 29, 2016 10:49 pm

Activating procedures with multiple buttons

Post by k.oneil » Mon Feb 29, 2016 11:13 pm

Hi! I'm a newbie to livecode and have been trying to get this action to happen:
- I want to press a 4 button sequence and make a image file open into a field
- I searched different tutorials and this forum but couldn't find an example...
- The 4th button "d" is a constant, so here's what I tried on "d" button script (the first 3 button will be different combinations, with a total of 14 buttons to choose from):
on MouseUp
if buttonPressed "a&b&c&d" is true
then
put file "fileName.png" into field "display"
end MouseUp

(Think of a "1 + 1 =" sequence). It's not working and I'm lost... Can anyone send some suggestions? Thank you so much! :D

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

Re: Activating procedures with multiple buttons

Post by dunbarx » Tue Mar 01, 2016 12:02 am

Hi.

Klaus. You need to move this into a new thread.

Mr. ONeil, please start new threads in, er, new threads.

Anyway, is the user pressing a series of actual buttons on a card? Or is it that four buttons on the keyboard are to be used. In fact, the code to do either will be nearly the same. It looks like buttons on the card.

So on a new card, make five buttons. For the first four, name them "A", "B", "C" and "D". The fifth button you might name "Start" and will have this in its script:

Code: Select all

global sequence

on mouseup
      put "" into sequence
end mouseup
In the card script:

Code: Select all

global sequence

on mouseup
   if "button" is in the target then put the short name of the target after sequence
   if sequence = "abcd" then
      answer "Bingo"
      put "" into sequence
   end if
end mouseup
Try clicking "ABCD" in order. Now restart, and try anything else at all. You will likely need more houseKeeping than what I provided. You owe me a little discussion about what is happening here.

Craig Newman
Last edited by dunbarx on Tue Mar 01, 2016 12:54 am, edited 1 time in total.

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

Re: Activating procedures with multiple buttons

Post by dunbarx » Tue Mar 01, 2016 12:51 am

Something just occurred to me. Would you allow a typo? That is, if the user typed "ABDCABCD", where the correct string "ABCD" is embedded in the total entry, but not exactly that entry, is that a hit?

If so, please think about how to implement. It involves changing just a few characters in the card script handler.

Craig

k.oneil
Posts: 2
Joined: Mon Feb 29, 2016 10:49 pm

Re: Activating procedures with multiple buttons

Post by k.oneil » Tue Mar 01, 2016 1:18 am

Hi Craig,

Thank you for your help... and my apology for not sending in the "correct thread", using a forum is new to me too! and I hope I'm not still in the wrong thread....

I'm going to try the global sequence suggestion (in the next couple days) and as far as the typo question... anything in addition to 3 buttons pushed would be ignored. This is a child's learning tool that I'm trying to keep simple. 1 + 1 = (image A file appears in field); 1 + 2 = (image A gone, image B file appears in field) etc. I've got everything else working; buttons highlight, numbers appear in field, welcome "hi" text - just can't figure out this last piece.

I appreciate your time and what's the best way to learn proper forum etiquette? Thanks!

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

Re: Activating procedures with multiple buttons

Post by dunbarx » Tue Mar 01, 2016 3:36 am

Proper forum etiquette is not being afraid to ask endless questions.

That said, you have to work hard while you are doing it.

Craig

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Activating procedures with multiple buttons

Post by Klaus » Tue Mar 01, 2016 2:46 pm

Hi friends,

Ok, I managed to split this thread! Hadn't this been a separate thread yesterday? 8)

Anyway, Mr. ONeil, it would be a good idea to get accustomed to the very basic concepts of Livecode by checking these stacks:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

Post Reply