Page 1 of 1

Trap hardware popup menu/windows key?

Posted: Wed Sep 14, 2011 12:23 am
by BarrySumpter
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

Re: Trap hardware popup menu/windows key?

Posted: Wed Sep 14, 2011 2:38 am
by sturgis
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)

Re: Trap hardware popup menu/windows key?

Posted: Wed Sep 14, 2011 3:03 am
by BarrySumpter
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.

Re: Trap hardware popup menu/windows key?

Posted: Wed Sep 14, 2011 3:49 am
by sturgis
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.

Re: Trap hardware popup menu/windows key?

Posted: Wed Sep 14, 2011 4:18 am
by BarrySumpter
Thanks again Sturgis,
Won't allow me to save nor change platforms.
But certaily worth a chase down.

Re: Trap hardware popup menu/windows key?

Posted: Wed Sep 14, 2011 5:23 am
by sturgis
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

Re: Trap hardware popup menu/windows key?

Posted: Wed Sep 14, 2011 5:48 am
by BarrySumpter
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.

Re: Trap hardware popup menu/windows key?

Posted: Wed Sep 14, 2011 7:27 am
by BarrySumpter
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.

Re: Trap hardware popup menu/windows key?

Posted: Thu Sep 15, 2011 1:29 am
by BarrySumpter
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.

Re: Trap hardware popup menu/windows key?

Posted: Thu Sep 15, 2011 2:33 am
by sturgis
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"

Re: Trap hardware popup menu/windows key?

Posted: Thu Sep 15, 2011 3:06 am
by BarrySumpter
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.

Re: Trap hardware popup menu/windows key?

Posted: Thu Sep 15, 2011 2:29 pm
by sturgis
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.

Re: Trap hardware popup menu/windows key?

Posted: Sun Sep 18, 2011 2:20 am
by BarrySumpter
Thanks sturgis.
And will do.

Re: Trap hardware popup menu/windows key?

Posted: Sat Jul 21, 2012 8:20 am
by Simon Knight
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

Re: Trap hardware popup menu/windows key?

Posted: Sat Jul 21, 2012 11:39 am
by BarrySumpter
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