Trap hardware popup menu/windows key?

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

Trap hardware popup menu/windows key?

Post by BarrySumpter » Wed Sep 14, 2011 12:23 am

I'd like to trap the android hardware popup menu/windows key.

Where android apps have a popup at the bottom of the screen for Delete/Search/Settings etc.

Anyone know how to trap the physical menu key on an Android mobile phone?

I know we can trap the backKey:

Code: Select all

on backKey
    if the number of this card is 1 then
        pass backKey
    else
        go to the previous card
    end if
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.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Trap hardware popup menu/windows key?

Post by sturgis » Wed Sep 14, 2011 2:38 am

Might try using rawkeydown to see if theres a key event when the button is pushed, and if so, see what the keycode is for that button.

on rawkeydown theKey
put theKey into field "my key monitoring field"
end rawkeydown

If this works, and you get a keycode then you can trap it also using the rawkeydown handler. You can decide based on theKey whether or not to pass rawkeydown.

At least thats my best guess without trying it out. (might need to use rawkeyup? Not sure if action is taken on key down or key up)

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

Re: Trap hardware popup menu/windows key?

Post by BarrySumpter » Wed Sep 14, 2011 3:03 am

Hi sturgis,

Thanks heaps for the acknowledgement.

Already tried RawKeyUp and RawKeyDown

Neither trap physical keys.

I can place another button on my card it just looks cluttered.

Any other suggestions from anyone would be greatly appreciated.
Last edited by BarrySumpter on Wed Sep 14, 2011 4:17 am, 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.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Trap hardware popup menu/windows key?

Post by sturgis » Wed Sep 14, 2011 3:49 am

Just had another thought. If you look at this post http://forums.runrev.com/viewtopic.php? ... 99&start=0 it talks about a message watcher that you can get from revnet (as per the instructions in the post) I'm wondering if it can be used on android to log whatever messages are sent when the buttons in question are pressed. If it works, all thanks go to Richard Gaskin of course.

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

Re: Trap hardware popup menu/windows key?

Post by BarrySumpter » Wed Sep 14, 2011 4:18 am

Thanks again Sturgis,
Won't allow me to save nor change platforms.
But certaily worth a chase down.
Last edited by BarrySumpter on Thu Sep 15, 2011 1:29 am, 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.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Trap hardware popup menu/windows key?

Post by sturgis » Wed Sep 14, 2011 5:23 am

Last shot then I'll quit buggin.

The reason you can't save or do anything with the stack from revenet is because its set to modeless. Need to toplevel the stack (either from the mssage box or double clicking the stack in the app browser) at which point you can check it out to your hearts content.

After looking it over, I made a very quick and dirty stack that shows pretty much every single event. (the 4w stack filters out quite a bit, my quick test stack filters nothing) But it looks like it wouldn't be too awful difficult to make one of your own.

I have a stack with 2 buttons and a field. The first button has the following.

Code: Select all

local tWatching

on mouseUp
-- setup my flag for watching or not
   if tWatching is empty then put false into tWatching
   put not tWatching into tWatching

-- set the button label to match the current state of the flag
   set the label of me to "Watching: " & tWatching

-- handler that starts the watching   
WatchIt
end mouseUp

command WatchIt
   if tWatching then -- if tWatching is true
     put empty into field 1 -- empty my output field on each start of watch 
     set the messageMessages to true -- set stack to receive messages about messages
   
-- insert the script of my other button into the front so it can catch things
   insert  script of btn "fScriptB" into front 
   else -- if tWatching is false
      set the messageMessages to false -- stop receiving messages about messages
      remove  script of btn "fscriptb" from front -- remove the other button script from the front
   end if
end WatchIt
Then the script that is in my button "fScriptB" is as follows.

Code: Select all

on messageHandled pType, pMessage
 -- does exactly what it seems like. Puts the message name, and the message type into field 1.
   put pMessage && pType & cr after field 1 of stack "mbWatcher" 
end messageHandled
Went ahead and made a standalone to make sure none of this stuff requires the IDE to be resident and it worked fine.
No way at this moment to test on android or IOS though so YMMV. (you should check out the 4w stack. It gave me a headache but worth the study)
Like I say, my sample is the absolute bare minimum, but hey. It works. Oh, and I also put the following into the closestack handler.

Code: Select all

 if "fscriptb" is in the frontscripts then remove script of button "fScriptB" from front

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

Re: Trap hardware popup menu/windows key?

Post by BarrySumpter » Wed Sep 14, 2011 5:48 am

You ain't buggin me.

... modeless ...
Don't know how to top level the stack via the msgbox.
I'm sure I double clicked via the app browser. no luck.

I'll build me own following your instructions.

Thanks heaps.
Last edited by BarrySumpter on Wed Sep 14, 2011 7:33 am, 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.

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

Re: Trap hardware popup menu/windows key?

Post by BarrySumpter » Wed Sep 14, 2011 7:27 am

Too easy with your instructions.
But Still no go.
Thanks heaps for trying anyway.
Certainly appreciate thinking outside the box.

If anyone else has any ideas I'm happy to have a go.
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: Trap hardware popup menu/windows key?

Post by BarrySumpter » Thu Sep 15, 2011 1:29 am

sturgis wrote:...
The reason you can't save or do anything with the stack from revenet is because its set to modeless. Need to toplevel the stack (either from the mssage box or double clicking the stack in the app browser) at which point you can check it out to your hearts content.
...
[/code]
In the app browser I haveto right click on the stack or the card and select TopLevel.
Then right on the stack or card again to get the app browser to show the objects.
Then right click not left click on the object in the app browser or on the card to edit script.
Thats right click not left click.

I wonder how much scripting I've been missiing out on not understanding how to get to it.
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.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Trap hardware popup menu/windows key?

Post by sturgis » Thu Sep 15, 2011 2:33 am

yeah, right click menu works. Not sure why the double click didn't work for you though unless your preferences differ from mine. (which is always very likely! I can fumble finger change things like nobodies business)

And through the message box it would be

toplevel stack "stackname"

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

Re: Trap hardware popup menu/windows key?

Post by BarrySumpter » Thu Sep 15, 2011 3:06 am

LOL!
Thanks for that clarification.

I've just confirmed with another 3rd party addon developer
that his addon wasn't working the same on my Win32 as his OSX.

Might be me converting .avi to .m4p and the double click was taking too long to respond.
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.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Trap hardware popup menu/windows key?

Post by sturgis » Thu Sep 15, 2011 2:29 pm

Hey, if you get the monitor working on android, and find a slew of undocumented but absolutely amazingly useful messages, a helpful list would be.. er.. helpful!

So good luck getting things cranked up.

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

Re: Trap hardware popup menu/windows key?

Post by BarrySumpter » Sun Sep 18, 2011 2:20 am

Thanks sturgis.
And will do.
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.

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Trap hardware popup menu/windows key?

Post by Simon Knight » Sat Jul 21, 2012 8:20 am

Did you find a method of accepting input from a physical button (i.e. a button that clicks) on an Android device ? I wish to control my app from a remote physical input and have discovered that the screen only responds to a finger.

Simon
best wishes
Skids

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

Re: Trap hardware popup menu/windows key?

Post by BarrySumpter » Sat Jul 21, 2012 11:39 am

I'm pretty sure one of the more recent updates included this ability.

Have a quick search of the users guide, release notes or the Android Release notes.
Hardware button support
When the user presses the hardware 'Back' key, a backKey message is sent to the current card of the
default stack. If the message is passed or not handle, the engine will automatically quit.
When the user presses the hardware 'Menu' key, a menuKey message is sent to the current card of
the default stack.
When the user presses the hardware 'Search' key, a searchKey message is sent to the current card of
the default stack.
here it is:
http://forums.runrev.com/phpBB2/viewtop ... key#p54219
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

Return to “Android Deployment”