Sending mouseup to checkboxes on different card

classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Sending mouseup to checkboxes on different card

Richmond Mathewson-2
  On 10/20/2010 09:28 PM, Bob Sneidar wrote:
> The rub lies in the fact that Revolution (WHOOPS! Sorry RunRev (WHOOP! Sorry LiveCode!))

That reminds me of the way Supercard and Toolbook kept changing
ownership . . .
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Sending mouseup to checkboxes on different card

charles61
This post has NOT been accepted by the mailing list yet.
In reply to this post by slylabs13
Bob,

Thanks very much for this information. I was trying to use the script that sent mouseUp commands to a series of checkboxes in my project that triggered a listing of only those checkboxes that were checked for printing purposes on separate printing pages. I used a group script that uses a custom property (uMyLabel) with a group script on each page for the checkboxes. 

The purpose of all this was to print just the checkboxes labels that were selected by the user. The big problem that I encountered was that when I saved the file and then opened it, the checkboxes were still checked but the print pages did not show the labels of the checkboxes that were checked. Of course this was to be expected. This was poor planning on my part because I decide near the end of my project not to print all of the checkboxes on cards, which was my original intention. And, because of my custom properties and group scripts, saving the print cards along with the cards that were marked turned into a nightmare!  

So, I thought perhaps a script that would trigger the checked checkboxes to show their labels on the print cards would be the way to go when the user click on a print button. I am currently testing Klaus script (see below) as a means of usin print cards for printing the marked cards 

on doStuff2
   ---> Script for marked cards!
   put the num of this card into tStartCard
   lock screen
   repeat with y = 1 to the number of cards

      

      if the mark of card y <> true then
         next repeat
      end if
      lock messages
      go card y
      unlock messages
      repeat with b = 1 to the number of buttons
         if the style of button b = "checkbox" then
            send "mouseUp" to button b
         end if
      end repeat
   end repeat
   lock messages
   go card tStartCard
   unlock messages
   unlock screen
end doStuff2

This more complicated that I would like. I usually use the print card method and hide buttons and set the background of the stack for my printing. 

Charles Szasz
[hidden email]




On Oct 20, 2010, at 2:28 PM, Bob Sneidar-2 [via Runtime Revolution] wrote:

The rub lies in the fact that Revolution (WHOOPS! Sorry RunRev (WHOOP! Sorry LiveCode!)) allows short references to objects. If you refer to "button 1", LiveCode resolves this internally to mean "button 1 of [the background the button belongs to if any of] the card I am currently looking at of the stack that card is in.

So when you call MouseUp for a button on another card, the card you are STILL IN is the one you are looking at, NOT the card the button is on which contains the mouseUp handler. By actually GOING to that card first (one method) "the card you are looking at" now means the one the button you are sending mouseUp to is on, because you just went there, and now the card and all it's objects are loaded into memory.

Now something to consider when writing scripts in buttons or any kind of card object like fields and menus and such, is that the scripts in the objects should not do anything that refers to objects not on the current card. Some would disagree with me, but I think this is a good practice in order to keep your code readable. Instead, handlers like that should be in card, background or stack scripts because of the kinds of issues you encountered.

For instance, if I have a script that modifies objects on each card, I would put that script in the stack script, because all the cards are in the stack. I could get the long names of all the cards of this stack, and then loop through each line to build the long names of all the objects I am referencing, but as noted above, it is often easier to lock the screen and then actually go to each card (as noted above). Also, I try to avoid doing any coding in buttons and fields and such that actually change anything. I call functions and commands in the card, background or stack scripts, depending on the scope of the command or function.

It's nice to have your code modular, so that it is contained in each object that calls it, but practically it gets to be a real pain later on when you have LOTS of handlers in LOTS of objects. Keeping track of where it all is becomes unmanageable in a hurry.

One more thing (and pardon my lengthy reply) but often people with past experience in Hypercard continue to use the method of having one card per bit of information to store their data. Just know that LiveCode is not really optimized for this, as many Hypercard importers have discovered. It's probably better to store your data in a custom property and design your cards as forms instead.

Just my 2ยข

Bob


On Oct 20, 2010, at 9:47 AM, charles61 wrote:

>
> Robert,
>
> I understand your previous e-mail about using custom handlers.  I have never used this concept before. But I am not following you when you sent the following:
>
> f one uses full reference in the called script (that is script in
> btn b of cd y refers to itself as btn b of cd y) then going to that
> card before running that script is not needed.
>
> While the script that Klaus posted works, I still want to fully understand your comments above. Could you elaborate further?
>
> Charles Szasz
> <a href="x-msg://85/user/SendEmail.jtp?type=node&amp;node=3004369&amp;i=0" target="_top" rel="nofollow">[hidden email]
>
_______________________________________________
use-revolution mailing list
<a href="x-msg://85/user/SendEmail.jtp?type=node&amp;node=3004369&amp;i=1" target="_top" rel="nofollow">[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution



View message @ http://runtime-revolution.278305.n4.nabble.com/Sending-mouseup-to-checkboxes-on-different-card-tp3003921p3004369.html
To unsubscribe from Sending mouseup to checkboxes on different card, click here.


Reply | Threaded
Open this post in threaded view
|

Re: Sending mouseup to checkboxes on different card

slylabs13
In reply to this post by Richmond Mathewson-2
Not complaining, just thought it was a funny thing to say. :-)

Bob


On Oct 20, 2010, at 11:52 AM, Richmond wrote:

> On 10/20/2010 09:28 PM, Bob Sneidar wrote:
>> The rub lies in the fact that Revolution (WHOOPS! Sorry RunRev (WHOOP! Sorry LiveCode!))
>
> That reminds me of the way Supercard and Toolbook kept changing ownership . . .
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Sending mouseup to checkboxes on different card follow-up

charles61
This post has NOT been accepted by the mailing list yet.
In reply to this post by Klaus on-rev
Hi Klaus,

I used the script below successfully in my project. 

on doStuff2
   put the num of this card into tStartCard
   lock screen
   repeat with y = 1 to the number of cards

      

      if the mark of card y <> true then
         next repeat
      end if
      lock messages
      go card y
      unlock messages
      repeat with b = 1 to the number of buttons
         if the style of button b = "checkbox" then
            send "mouseUp" to button b
         end if
      end repeat
   end repeat
   lock messages
   go card tStartCard
   unlock messages
   unlock screen
end doStuff2

It worked great except for one card where I have several allergies listed by checkboxes. The user checks the checkbox that applies to the user. Then on the next card the allergy selected by the user appears by itself in a field. This is accomplished by the following group script:

on mouseUp
   put empty into field "other"
   --   disable field "other"
   put the number of buttons of me into nbr
   repeat with n = 1 to nbr
      put the short name of button n of me into tName
      if not the hilite of button n of me then next repeat
      put tName & ", " after theList
   end repeat
   delete char -2 to -1 of theList
   put theList into field "disability" of card "other"
   put theList into field "allergyName" of card "allergy2"  --> second card
end mouseUp


When I used the first script the checkbox for the allergy selected is correctly checked on the first card but its name does not appear on the second card, in sense overrides the second script. Any suggestions on how to correct this problem?

Charles Szasz
[hidden email]




On Oct 20, 2010, at 12:05 PM, Klaus on-rev [via Runtime Revolution] wrote:

Hi Charles,

> Robert,
>
> I tried your suggestion. But I get the same results: the checkboxes received the message on the first card but the checkboxes on the second card did not receive the mouseUp message.
>
> Charles Szasz
> <a href="x-msg://154/user/SendEmail.jtp?type=node&amp;node=3004174&amp;i=0" target="_top" rel="nofollow">[hidden email]

your script is OK!
But check Roberts answer, that is what's going on on your side!

>> ...
>> Anyway, your script may fail if your mouseup function does sth that
>> refers to the buttons on the other card, which are not present on the
>> current card and it does not make full reference to them but only
>> uses short names.

To avoid this and other traps when sending "mouseup" to object on other cards you coul do this and
since there is no "defaultCard" (like "defaultstack") that we can set, we have to go to all the cards to
avoid this above mentioned phenomenon!

on mouseUp
 ## We want to return to this card after the script has finished!
 put the num of this cd into tStartCard
 lock screen
  repeat with y = 1 to the number of cards
 
  ## We actually have to GO to the cards but to avoid unnecessary
  ## PRE/OPENCARD messages we have to:
 lock messages
 go cd y
 unlock messages
     repeat with b= 1 to the number of buttons
        if the style of button b  = "checkbox" then
           if the hilite of button b  = "true" then
               send "mouseUp" to button b
           end if
       end if
     end repeat
end repeat

## Go back
 lock messages
 go cd tStartCard
 unlock messages
 unlock screen
end mouseUp

>>
>> Robert

Best

Klaus

--
Klaus Major
http://www.major-k.de
<a href="x-msg://154/user/SendEmail.jtp?type=node&amp;node=3004174&amp;i=1" target="_top" rel="nofollow">[hidden email]

_______________________________________________
use-revolution mailing list
<a href="x-msg://154/user/SendEmail.jtp?type=node&amp;node=3004174&amp;i=2" target="_top" rel="nofollow">[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution



View message @ http://runtime-revolution.278305.n4.nabble.com/Sending-mouseup-to-checkboxes-on-different-card-tp3003921p3004174.html
To unsubscribe from Sending mouseup to checkboxes on different card, click here.


Reply | Threaded
Open this post in threaded view
|

Sending mouseup to checkboxes on different cards

charles61
This post has NOT been accepted by the mailing list yet.
In reply to this post by Klaus on-rev
Hi Klaus,

I used the script below successfully in my project. 

on doStuff2
   put the num of this card into tStartCard
   lock screen
   repeat with y = 1 to the number of cards
      
      if the mark of card y <> true then
         next repeat
      end if
      lock messages
      go card y
      unlock messages
      repeat with b = 1 to the number of buttons
         if the style of button b = "checkbox" then
            send "mouseUp" to button b
         end if
      end repeat
   end repeat
   lock messages
   go card tStartCard
   unlock messages
   unlock screen
end doStuff2

It worked great except for one card where I have several allergies listed by checkboxes. The user checks the checkbox that applies to the user. Then on the next card the allergy selected by the user appears by itself in a field. This is accomplished by the following group script:

on mouseUp
   put empty into field "other"
   --   disable field "other"
   put the number of buttons of me into nbr
   repeat with n = 1 to nbr
      put the short name of button n of me into tName
      if not the hilite of button n of me then next repeat
      put tName & ", " after theList
   end repeat
   delete char -2 to -1 of theList
   put theList into field "disability" of card "other"
   put theList into field "allergyName" of card "allergy2"  --> second card
end mouseUp


When I used the first script the checkbox for the allergy selected is correctly checked on the first card but its name does not appear on the second card, in sense overriding the second script. Any suggestions on how to correct this problem?


Charles Szasz
[hidden email]




12