changing menupick item action depending on current card

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

changing menupick item action depending on current card

Post by Martin Koob » Thu Oct 09, 2008 4:33 pm

I have a menu item in a menu that performs different actions depending on which card is the current card. I thought I could do this by using 'this card' to determine the current card and run the correct command.

Code: Select all

on menuPick pWhich
   switch pWhich
    
      case "Open Project File..."

      If this card  is "browse" then
         Send "mouseup" to button "Open Project"
       else if this card  is "record" then
           Send "mouseup" to button "recordOpenProject"
        end if
      break
     case "New Project file..."
         ....
      break
If I run that I get the following error.

Type Chunk: source is not a container
Object File
Line If this card is "browse" then
Hint menuPick
I have tried the same script with

Code: Select all

'If the current card  is "browse" then'
...
and get a similar error message.

How do I determine in a menu script what the current card is. Any suggestions?
[/code]

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Post by Klaus » Thu Oct 09, 2008 4:59 pm

Hi Martin,

you are looking for "the short name of this cd" :-)

Code: Select all

on menuPick pWhich
   put the short name of this cd into name_o_cd
   switch pWhich    
      case "Open Project File..." 
      switch name_o_cd
          case "browse" 
             Send "mouseup" to button "Open Project" 
          break
          case "record" 
             Send "mouseup" to button "recordOpenProject" 
          break
       end switch
      ## I prefer "switch" instead of unreadable nested "it...then" structures ;-)

      break 
     case "New Project file..." 
         .... 
      break 
Best

Klaus

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Post by Martin Koob » Fri Oct 10, 2008 1:06 am

Thanks Klaus, that did the trick.

Martin

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”