How to remove hilite from previously selected button.

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

How to remove hilite from previously selected button.

Post by BarrySumpter » Fri Mar 30, 2012 8:44 am

I have a Login screen with a Green Login button (Icon).
When I mouse over (hover) in win32 or select/tap n hold
the button turns red (Hover Icon).

Then if I press that button the button turns grey (Hilite Icon)
and takes me to my content card.

If I go back to that Login card the button is green while
the page is turning.

Then turns back to grey as soon at the page stops turning.

On my previous projects I thougt it was a residule touch
that would turn the button to grey again.

But its the last status the button was in when the card was last visible.

So to switch the Hilite off for the button:

Code: Select all

on openCard
   --This fixes the Grey(Hilite Icon) Login button back to Green(Icon)
   if the hilite of button "Login" is true then
      set the hilite of button "Login" to false
   end if
end openCard

Last edited by BarrySumpter on Fri Mar 30, 2012 11:36 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

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

Re: How to remove hilite from previously selected button.

Post by jacque » Fri Mar 30, 2012 6:12 pm

You need to add a mouseRelease handler. MouseRelease fires when the mouse was pressed on a control but released outside the control, which is the case when you go to another card if the card change is triggering on a mousedown.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: How to remove hilite from previously selected button.

Post by BarrySumpter » Fri Mar 30, 2012 11:28 pm

I found this:

Code: Select all

on mouseRelease theButton
  if theButton is 1 then send "mouseUp" to the target
  else pass mouseRelease
end mouseRelease
Handle the mouseRelease message to perform an action when the user releases the mouse button after clicking and then dragging outside the control.

Parameters:
The mouseButtonNumber specifies which mouse button was pressed:
* 1 is the mouse button on Mac OS systems and the left button on Windows and Unix systems.
* 2 is the middle button on Unix systems.
* 3 is the right button on Windows and Unix systems and Control-click on Mac OS systems.

Comments:
The mouseRelease message is sent to the control that was originally clicked, or to the card if no control was under the mouse pointer.

The mouseRelease message is sent only when the Browse tool is being used.

If an unlocked field is clicked with mouse button 1 or 2, no mouseRelease message is sent.

If the control is a field with its listBehavior property set to true, the mouseRelease message is sent when the mouse button is released and the mouse is not over a text line in the field, even if the mouse is still over the field.

If the mouse is released while it's still within the control that was clicked, a mouseUp message is sent instead of mouseRelease.

----

I've placed it in various places but to no effect.

Any suggestions?

I've modified the script in the original post to check the hilite first.
It's working.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to remove hilite from previously selected button.

Post by bn » Fri Mar 30, 2012 11:39 pm

Hi Barry,
I've placed it in various places but to no effect.
put it into the control that you want to get the message. E.g. a button has a mouseUp handler which is only triggered if the mouse if over the button when it goes up. Add a mouseRelease handler to the button, it will then fire the mouseUp as to the script you posted.

If you handle your mouseUp/mouseRelease for a lot of buttons in the card script you would have to add

Code: Select all

if the short name of the target is "myButtonx" then
If you use a behaviour script for your controls put your "on mouseRelease" handler into the behaviour script.

Of course you don't have to send the mouseUp in your mouseRelease handler, you could also take a different action on mouseRelease.

Kind regards

Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to remove hilite from previously selected button.

Post by bn » Sat Mar 31, 2012 12:21 am

Hi Barry,

here is a little stack that shows mouseRelease/mouseUp
mouseUp-Release.livecode.zip
(1.28 KiB) Downloaded 314 times
Kind regards

Bernd

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: How to remove hilite from previously selected button.

Post by BarrySumpter » Sat Mar 31, 2012 7:13 am

Nope my bad.
I was thinking my code was working - but its not.
If I select another control the original button somehow turns back to green.
Perhaps the origninal mouseup gets processed as well?

But if I select backKey the button stays red.
As if it's hilite is still true.

Code: Select all

on backKey
   visual effect push right fast
   go to card "Card1"
   --set the hilite of button "Login" of card "Login" to false
end backKey
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: How to remove hilite from previously selected button.

Post by BarrySumpter » Sat Mar 31, 2012 8:04 am

I should have posted my sample app first.

Still can't get it to work.

I don't understand why this has to be so complicated (for me).

Is there a ResetCard or some such?
Attachments
mouseUp-Release.zip
(16.21 KiB) Downloaded 296 times
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to remove hilite from previously selected button.

Post by bn » Sat Mar 31, 2012 11:20 am

Hi Barry,

if I understand you correctly what bothers you is that your button "Get" is first green and then grey when you return from card 2 to card 1.

The reason for this is that if you click on the button "button" on card 2 you are within the location where your button "Get" is on card 1. This leads to the following sequence of events.
You press button "Button" on card 2 and you go as per your script to card 1. Assuming you did not move your mouse after clicking: The transition takes place and the button "get" is in its green default state. When the transition is completed button "get" is under the mouse. Dutifully button "Get" turns on its grey hover state.

I changed a couple of things in the stack. The button "Get" was huge, I reduced its height to the smallest possible height without cutting off the reflection effect in the image. This will help that the button is not accidentally click since it extended invisible far beyond the visible area.
I moved down the button "Button" on card 2. That way when you click button "Button" on card 2 and don't move your mouse the mouse will not be over button "Get" when the transition to card 1 is finished and the hover state of button "Get" is not activated.
I blocked "focus on field 1" in the script of button "Button" on card 2. No need for that and beside it throws an error since field 1 has its focusable set to false.

So basically nothing wrong with your scripts. You don't need a mouseRelease in this context, in fact it would prevent the user from cancelling his mouseDown by moving away from the button. If you would add a mouseRelease no way for the user to bail out.

If you are doing this for mobile deployment you really dont need a hover state of a button since in a touch GUI it is either up or down. No hovering.

I hope I understood your problem correctly and post your stack with changes back.
mouseUp-Release Barry_2.livecode.zip
(16.67 KiB) Downloaded 321 times
Kind regards

Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to remove hilite from previously selected button.

Post by bn » Sat Mar 31, 2012 11:45 am

Oh, and by the way: your code would probably work on a touch device since there is no hovering.

Kind regards

Bernd

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: How to remove hilite from previously selected button.

Post by BarrySumpter » Sat Mar 31, 2012 12:07 pm

Hi Bernd,

Thanks for sticking with this.

The hover I'm using to acknowledge a press and long press on the android.

I'm using the backKey which is the physical back key on the phone and NOT a LC button.
My second card is actualy a map and has no buttons.

Are you using the phyical back button on an actual andoird.
I only ask cause its not working on either of mine.

Been up since 3am this morn so getting a bit ditsier than usual.
I remember spending hours on this last time as well.

It might best we put this away and press on with other things.

By the way, love how easy to code that red dot was.

Completly loosing my focus now.

Sincerely appreciate the help.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Post Reply