I am currently writing a J2ME app for a card game which begins at a menu screen which gives the option to select a number of different card games to play.
This menu screen is a form and I need to know how to navigate to the new form for the games.
public void commandAction(Command c, Displayable s) {
if(c.equals(exitComm)){
}
else if(c.equals(gameComm))
{
//start the queen game...create instance of QueensForm
QueensForm form = new QueensForm(null, "Queens");
display.setCurrent(form);
System.out.println("pressed play");
}
As it stands the app compiles and runs, however when the play button is clicked an error occurs and it says the problem is on the line display.setCurrent(form); I am unsure of the problem and was wondering if anybody could help me to sort this out or suggest a better way to navigate throughout the forms in the app.
Related
I am having issues with my app returning to the foreground every time the user presses the back button. I believe this may be because there is a sound playing module that restarts the activity although this is just my hypothesis. However whenever I press the home (middle) button the app is sent to the background and everything works accordingly. I would like to emulate this functionality by capturing the back press event and handle it in a similar manner to the home button. While navigating the source, i've found the following handler in
android/reactnativenavigation/layouts/SingleScreenLayout.java
#Override
public boolean onBackPressed() {
if (handleBackInJs()) {
return true;
}
if (stack.canPop()) {
stack.pop(true, System.currentTimeMillis());
EventBus.instance.post(new ScreenChangedEvent(stack.peek().getScreenParams()));
return true;
} else {
return false;
}
}
I can understand at a glance what is being done however I am not very familiar with Java and don't want to introduce any bugs involving the native side of the app, could anyone kindly point out what I would need to modify?
So, you need to capture "the hardware back button" press not the home button right?
check here for the react-native way of doing it
I'm using CUITe to automate the testing of a UI piece (captured as a Page Object model).
I have a class that captures the buttons in my UI, like so:
class Navigators : CUITe_BrowserWindow
{
public new string sWindowTitle = "Window";
public CUITe_HtmlInputButton next = new CUITe_HtmlInputButton("Id=Content_btnNext");
// Other such buttons
//And a method to click any button
public void ClickButton(string id)
{
CUITe_BrowserWindow.GetBrowserWindow<Navigators>().Get<CUITe_HtmlInputButton>(string.Concat("Id=", id)).Click();
}
}
And the test I'm trying to automate is this, the click of a button:
CUITe_BrowserWindow.Launch<Navigators>("url");
CUITe_BrowserWindow.GetBrowserWindow<Navigators>().ClickButton("Content_btnNext");
My problem is this:
When I project my screen to a secondary monitor and extend it, the 'Next' button is clicked perfectly. However, on my system, the mouse passes over the button to another position and the click doesn't happen.
I have tried refreshing the CodedUI cache (by setting SearchConfiguration to Always), but that hasn't worked. Also, SetFocus on the control works correctly, whereas DrawHighlight shows the wrong position.
Any help would be greatly appreciated.
EDIT
When I changed my screen's resolution to 1440x900 (which is that of the secondary monitor's), the click happened.
I would be glad if someone could provide links that show how to handle screens of different resolutions in Coded UI
This is how I click controls on Win 8.1 store app which may or maynot be of help to you:
Mouse.Click(new Microsoft.VisualStudio.TestTools.UITest.Input.Point(uiControl.Left + (uiControl.Width / 2), uiControl.Top + (uiControl.Height / 2)));
Below is how I've been doing it in my CUITe scripts & it works fine at 1920x1080 on my larger monitor & at 1280x1024 on my laptop screen.
Given your OR definition above.
using Navigators.ObjectRepository; //guessing the name here
var pgNavigator = new Navigators();
//whatever else you do before clicking on next
Navigators.next.Click();
I have a simple iPhone app with a simple view and a custom view as a child. The child is just a square painted on the main view.
I need to track a touch event that enters this child view but from a touch that started outside the view.
What I've tried so far is to add the TouchesBegin/TouchesMoved events to the parent view. Also tried to add the to the child controls directly but that doesn't track any touches that are not initiated within that control.
The questions are:
a) can I get the control from Position somehow?
b) is this the best way doing this, or is there another way?
Again, I include this video of GamePlay for the game I'm trying to port (on my spare time). It's not a promotion attempt but illustrates what I'm trying to accomplish. I wrote the Win8 and WP7 version of the game so I'm not trying to copy another persons work here. :) Don't watch it if you don't want to know what game it is. The question is still valid without watching this.
http://www.youtube.com/watch?v=13IczvA7Ipo
Thanks
// Johan
I stumbled on the answer myself. In the parent I override TouchesMoved (and Begin and Ended not shown here).
I then iterate the subviews and chech if it's the view I'm looking for by type and then check if the Frame contains the point. The code below is just concept of course.
public override void TouchesMoved (NSSet touches, UIEvent evt)
{
base.TouchesMoved (touches, evt);
UITouch touch = touches.AnyObject as UITouch;
if (touch != null) {
var rp = touch.LocationInView (touch.View);
foreach(var sv in this.View.Subviews)
{
if(!(sv is LetterControl))
continue;
if(sv.Frame.Contains (rp))
{
Console.WriteLine("LetterControl found");
}
}
}
}
i have a game developed using LWUIT.now i am implementing full touch in game.it is a multi player game so there are some options like chat and login. when we press on chat we need to enter the characters in the field. my question is
is it possible to invoke the native keypad when we press on the chat button .?
thanks in advance
kris
No. MIDP doesn't include such an API. You can use LWUIT's virtual keyboard (which isn't native) and define any character set you want as explained here:
http://lwuit.blogspot.com/2010/06/pimp-virtualkeyboard-by-chen-fishbein.html
You can show it using the display class.
On Symbian devices if you do not define some jad properties, a touch keypad will be always visible and you won't be able to hide it for more details look here:
http://lwuit.blogspot.com/2009/11/optimized-for-touch.html
Looking at the question again I'm thinking the VKB is probably an overkill for an always on keypad replacement. Just place your content in the center of a BorderLayout and stick a container in the south something like this:
addComponent(BorderLayout.CENTER, myUI);
Container keypad = new Container(new GridLayout(2, 2));
addComponent(BorderLayout.SOUTH, keypad);
Button up = new Button("Up");
Button down = new Button("Down");
Button left = new Button("Left");
Button right = new Button("Right");
up.setFocusable(false);
down.setFocusable(false);
left.setFocusable(false);
right.setFocusable(false);
keypad.addComponent(up);
keypad.addComponent(down);
keypad.addComponent(left);
keypad.addComponent(right);
up.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
int up = Display.getInstance().getKeyCode(Display.GAME_UP);
Display.getInstance().getCurrentForm().keyPressed(up);
Display.getInstance().getCurrentForm().keyReleased(up);
}
});
The rest and fire are pretty trivial to add (same thing) notice that getKeyCode is deprecated but should work for now since we have no alternative to that API.
According to the documentation, Display.setCurrent doesn't work if the current displayable is an alert. This is a problem as I would like to pop up another alert when the user selects a command. Does anyone know how to work around this so that we can go from one alert to another? I am using CLDC 1.0 and MIDP 2.0.
Additional Information
The spec does allow us to edit an alert while it is on screen, but some Nokia phones don't handle it well at all. So I am now trying to go from the alert to a blank canvas, then back to the alert. Of course I don't want the user to interact with the previous canvas, so it seems that I am forced to create a new blank canvas. As a sidenote, this has the slight disadvantage of looking worse on phones which still have the previous screen when an alert is shown.
The bigger problem is how to transition from the blank canvas back to an alert once the canvas is loaded. Testing on the Motorola emulator revealed that showNotify is not called after returning from an alert to the previous screen. I guess I could create the next alert in the paint method, but this seems like a ugly hack.
OK, so your problem is that you can't set it up to do:
Display.setCurrent(alert1, alert2);
and
Display.setCurrent(alert2);
is also not possible if the current Displayable is already alert1.
So how about put an intermediate Displayable item that is blank and that immediately changes to the next alert? Assuming the current Displayable is alert1, like this in your alert1's command block:
Display.setCurrent(blankForm);
Display.setCurrent(alert2);
That should work assuming you are not using the default 'Dismiss' command. So basically it goes from alert1->(blankForm->alert2).
I couldn't find a way around this, so I just used the paint hack.
public class AlertPage extends Canvas{
MIDlet midlet;
Alert alert;
private AlertPage(MIDlet midlet){
this.midlet=midlet;
}
protected void paint(Graphics arg0){
//Yep, this is a hack, but showNotify doesn't seem to work well for Motorola
if(alert!=null){
Display d=Display.getDisplay(midlet);
d.setCurrent(alert);
alert=null;
}
}
public static void showAlert(MIDlet m, Alert a){
AlertPage page=new AlertPage(m);
Display d=Display.getDisplay(m);
page.alert=a;
d.setCurrent(page);
}
}