Android "back" button vs Desktop "Escape" key - javafxports

I am writing an app using JavafxPorts that I am planning on running on both Android and Desktop (PC).
I am trying to keep my code as generic as possible.
My question is... how can I support both the "back" button on Android and have it be equivalent to the "Escape" key on PC?
Basically I want to bring up the menu when the back button is pressed on Android or if the Escape key is pressed on PC.
Thanks!

JavaFXPorts already has support for the back button on Android: it is mapped to the Escape key.
You can also use Gluon Charm Down, an OSS project that will let you easily find out about the platform you are running.
public void start(Stage primaryStage) {
Scene = new Scene(...);
scene.addEventHandler(KeyEvent.KEY_RELEASED, e -> {
if (KeyCode.ESCAPE.equals(e.getCode())) {
if (JavaFXPlatform.isAndroid()) {
// bring up the menu or other Android stuff
} else {
// bring up the menu or other Desktop stuff
}
});
}
}

Related

Can't re-open a Qt app if I reimplement QCloseEvent

I'm trying to let the app hide to dock when user click on the close button.
So I implemented QCloseEvent:
void xxx::closeEvent (QCloseEvent *e)
{
hide ();
e->ignore ();
}
Now if I click on close button, it works but I can never bring it back
Nothing happens when I click on the dock
I guess I'm missing an event? What should I do now?

Sencha Touch - Windows Phone 8 Phonegap Application Bar not hiding on back button click

We are developing an hybrid mobile application using Sencha touch 2 for Windows Phone 8.
While developing we noticed that for a number field in windows phone 8 there is no keyboard done button available.Please refer to the below screenshot.
We then decided to write a custom application bar in Windows Phone 8 - Phonegap application inside the MainPage.cs with an Done button inside that application bar.Please refer to the below screenshot.
Now the done functionality works fine but when we click on the back button of the device the keyboard hides but the application bar remains in the view as in the below screenshot
We tried overriding the back button functionality in phonegap, but when the keyboard is shown the back button click is fired only the second click ,the first click hides the keyboard and the second click fires the overridden function.
Can someone provide some alternatives or a solution on how to hide the custom application bar along with the keyboard when the back button is clicked the first time ?
In MainPage.xaml.cs add listener mentioned below which listens the event when back button is pressed in device when keypad is opened.
And pass a string from java script when ur calling particular plugin to show the application bar contains done button, by using that you can identify in which case you have to show and other case you can hide the bar.
cordova.exec(null, null, "Cordova.Extension.Commands.DoneButtonPlugin", "keyboardDoneShow", "Num");
cordova.exec(null, null, "Cordova.Extension.Commands.DoneButtonPlugin", "keyboardDoneHide", "input string");
private void CordovaView_LayoutUpdated(object sender, EventArgs e)
{
if (CordovaView.Content.DesiredSize.Height == 0)
{
if(App.appBar.IsVisible)
App.HideShell();
}
else
{
if (App.NumKey == "\"Num\"") {
if(!App.appBar.IsVisible)
App.ShowShell();
}
}
}

Air: How to put a NativeWindow over OSX menu bar?

I'm developing a multi monitor fullscreen application with Adobe Air 2.6.
I can create a window for every monitor, and put those windows to fullscreen.
theWindow.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
The problem comes when interacting with those windows. If I click the window on the main monitor (the one with the dock and menu bar) no problem, but when I click any other window the system menu bar becomes visible.
I've tried resizing the main window to match the monitor size and moving it to a negative coordinate but it always stays behind the bar.
Is it possible to do this in Air?
Should I look for another solution?
I was able to go full FULL_SCREEN_INTERACTIVE using AIR 3.1 (Flex 4.6 SDK) on OSX using a terrible timer hack:
public function initializeView():void
{
var horridFullscreenTimer:Timer;
horridFullscreenTimer = new Timer(100,1);
horridFullscreenTimer.addEventListener(TimerEvent.TIMER,initializeViewForReal);
horridFullscreenTimer.start();
}
public function initializeViewForReal(event:TimerEvent=null):void
{
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, handleStageResize);
}
Solution was found in this thread: http://forums.adobe.com/thread/108170

How to disable back button of windows phone after one click

I have a problem in my app is that when the user hit back button multiple times the app become crashed.Is there any way to handle this problem ?Is any way to disable back button after the first click from a page.so further click can be avoided.The exception i am getting while hitting back button multiple time is 0x8000ffff.Is there any solution for this in windows phone 7.1?
You should fix the issue which is causing your app to crash. If you disable the back button behaviour you risk failing marketplace certification due to requirement 5.2.4[.1] http://msdn.microsoft.com/en-us/library/hh184840(v=VS.92).aspx
You can control that, here is a sample code:
private void YourPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
//App.NaviService.BackKeyPress(sender, e);
if (NavigationService.CanGoBack)
{
NavigationService.GoBack();
}
}

Pressing the device's back button do we have to close the Message box and cancel the backwards navigation too in WP7?

In the Certification guidelines 5.2.4 C they mentioned that if the current page displays a context menu or a dialog, the pressing of the Back button must close the menu or dialog and cancel the backward navigation to the previous page.
Is this applicable for MessageBox also?
I am using MessageBox to prompt the user to allow the location service api to use location i.e. lat and long which is in application launching.
Do I have to follow the 5.2.4 C for the MessageBox too be closed and stop back navigation.
Please guide me for standard way to implement so not to fail in Windows phone 7 Certification process.
4.Check the Back button Twice:
protected override void OnBackKeyPress( System.ComponentModel.CancelEventArgs e )
{
if (DemoPopup.isOpen)
{
e.Cancel = true;
//hide the popup
DemoPopup.IsOpen = false;
}
else
{
base.OnBackKeyPress(e);
}
}
Yes, if you have a Message Box displayed (or a Context Menu) then pressing the back button should dismiss the Message Box instead of navigating backwards, i.e. backwards navigation should not occur.
However, in the case of MessageBox.Show and ContextMenu (from the Silverlight Toolkit), I think this happens for you automatically.

Resources