button hilite problem

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
edwardeddyus
Posts: 10
Joined: Mon Mar 25, 2013 7:17 pm

button hilite problem

Post by edwardeddyus » Wed Nov 12, 2014 10:08 pm

Ok I have the following it works perfect on iOS and hilites the button you click on but on my android device it selects the button and after the move group completes it hilites another button so there are two buttons hilited. Please help I've already released this app and I have to fix fast!!

Code: Select all

on mouseUp
   submenu  the short name of me
end mouseUp
command submenu mitem
   local ar
   local x
   local y
   local mLoc 
   local b
   local c
   playclick
   put the loc of group "MainData" on this card into mLoc 
   split mLoc by comma
   
   put mLoc[1] into x
   put mLoc[2] into y
   
   put x into b
   replace "-" with "" in b
   
   put y-(the height of field "Generic" on this card) into c
   
   put "MainData"  into ar["medinfo" ]
   put "Purpose Data"  into ar["purpose" ]
   put "Dose Data" into ar["dose" ]
   put "Side Effects Data"  into ar["side effects" ]
   put "Emergency Conditions Data" into ar["Emergency cond" ]
   put "Abuse Potential Data" into ar["Abuse Potential" ]
   put "Cautions Data" into ar["Cautions" ]
   put "Pregnancy Data" into ar["Pregnancy" ]
   
   put the formattedLeft of group "MainMenu" on this card into cleft
   replace "-" with "" in cleft
   set the hScroll of group "MainMenu" on this card to cleft + the left of button mitem of group "MainMenu" on this card
   
   repeat for each key tKey in ar
      if tKey is "medinfo" then
         move group ar[tKey] on this card to -b,y in 0.5 second
      else
         if exists(group ar[tKey] on this card) then
            put the loc of group ar[tKey] on this card  into dLoc 
            split dLoc by comma
            if dLoc[1] is not -b then
               move group ar[tKey] on this card  to -b,c in 0.5 second
            end if
         end if
      end if
   end repeat
   
   if mitem is "medinfo" then
      set the visible of field "Generic" on this card to true
      set the visible of field "Brand" on this card to true
      move group ar[mitem] on this card  to b,y in 0.5 second
   else
      set the visible of field "Generic" on this card to false
      set the visible of field "Brand" on this card to false
      if exists(group ar[mitem]) then
         move group ar[mitem] on this card  to b,c in 0.5 second
      end if
   end if
   
   //Reset hilites
   repeat for each key tKey in ar
      if tKey is mitem then
         set the hilite of button mitem of group "MainMenu" on this card to true
      else
           set the hilite of button tKey of group "MainMenu" on this card to false
      end if
   end repeat
   select group "MainData" on this card
end submenu

edwardeddyus
Posts: 10
Joined: Mon Mar 25, 2013 7:17 pm

Re: button hilite problem

Post by edwardeddyus » Thu Nov 13, 2014 5:55 pm

Ok after hours of searching and no luck I discovered it's the hover icon causing the issue set all the hover icons to 0 and now it works fine.

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

Re: button hilite problem

Post by Klaus » Thu Nov 13, 2014 8:03 pm

Hi Edward,
edwardeddyus wrote:Ok after hours of searching and no luck I discovered it's the hover icon causing the issue set all the hover icons to 0 and now it works fine.
great!

Some general hints:
1. the correct syntax is: btn x of grp x OF this cd ## not ON this cd
2. Really no need to specify "...of THIS cd", if you save some typing and omit it, it will be found nevertheless!
3. No need to create an array for X and Y coordinates of an object's loc, just use ITEMs:
...
put the loc of btn X into tLoc
## -> 100,250
## DEFAULT item delimiter = COMMA, so you can:
put item 1 of tLoc into tX
put item 2 of tLoc into tY
...
Or if they might be negative but you need their ABSOLUT values:
...
put ABS(item 1 of tLoc) into tX
put ABS(item 2 of tLoc) into tY
...

Best

Klaus

edwardeddyus
Posts: 10
Joined: Mon Mar 25, 2013 7:17 pm

Re: button hilite problem

Post by edwardeddyus » Thu Nov 13, 2014 8:55 pm

Thanks for the tips I'm new to this language so I thought since I created the command on the stack I may need to maintain hierarchy. I may have been having a flash back to my days of writing ActionScript :)

Post Reply