Picker not showing at the right moment - codenameone

I am experiencing some weird behavior with the pickers in my app since the pixel perfect picker update : The picker is showing when the form is called to be show, so before the form is showing.
I've tried with the new lightweight mode, with the old mode, inside a PickerComponent, with just a picker, on Android 7, iOS 10 and the simulator, all have a similar behavior.
The only difference is that with a PickerComponent, the bug appear when the Form is shown a second time.
The bug occur once, because I keep my forms in memory most of the time and it occur only the first time.
Here is a little code sample to add in the start method of the barebone hello world :
Picker pick = new Picker();
pick.setType(PICKER_TYPE_STRINGS);
pick.setStrings("First model", "Second model", "Third model");
pick.addActionListener(e->Dialog.show("Picker result", pick.getSelectedString(), "OK", null));
pick.setUseLightweightPopup(false);
Picker pick2 = new Picker();
pick2.setType(PICKER_TYPE_STRINGS);
pick2.setStrings("First model", "Second model", "Third model");
pick2.addActionListener(e->Dialog.show("Picker result", pick2.getSelectedString(), "OK", null));
pick2.setUseLightweightPopup(true);
PickerComponent pickerComponent = PickerComponent.createStrings("First model", "Second model", "Third model").label("Model Heavy");
pickerComponent.getPicker().setUseLightweightPopup(false);
pickerComponent.getPicker().addActionListener(e->Dialog.show("Picker result", pickerComponent.getPicker().getSelectedString(), "OK", null));
PickerComponent pickerComponent2 = PickerComponent.createStrings("First model", "Second model", "Third model").label("Model Light");
pickerComponent2.getPicker().setUseLightweightPopup(true);
pickerComponent2.getPicker().addActionListener(e->Dialog.show("Picker result", pickerComponent2.getPicker().getSelectedString(), "OK", null));
Form hi = new Form("PickerCompo Heavy", BoxLayout.y());
hi.add(pickerComponent);
Form hi2 = new Form("PickerCompo Light", BoxLayout.y());
hi2.add(pickerComponent2);
Form hi3 = new Form("Picker Heavy", BoxLayout.y());
hi3.add(pick);
Form hi4 = new Form("Picker Light", BoxLayout.y());
hi4.add(pick2);
Form caller = new Form("Call Hi World", BoxLayout.y());
Button callForm = new Button("hit me heavyweight Compo");
callForm.addActionListener(e->{
hi.setBackCommand("Back", null, ev-> caller.showBack());
hi.show();
});
Button callFormLight = new Button("hit me Lightweight Compo");
callFormLight.addActionListener(e->{
hi2.setBackCommand("Back", null, ev-> caller.showBack());
hi2.show();
});
Button callForm3 = new Button("hit me heavyweight");
callForm3.addActionListener(e->{
hi3.setBackCommand("Back", null, ev-> caller.showBack());
hi3.show();
});
Button callForm4 = new Button("hit me Lightweight");
callForm4.addActionListener(e->{
hi4.setBackCommand("Back", null, ev-> caller.showBack());
hi4.show();
});
caller.add(callForm);
caller.add(callFormLight);
caller.add(callForm3);
caller.add(callForm4);
caller.show();
Any idea of a workaround ? I'm using them on some major forms in my app, and I'd like to update the app to resolve the distorting screen on iOS (SO : Distorted screen ).

There was a regression with Picker due to changes in the focus functionality that were used with the Picker change but are applicable even in the native functionality.
This should be fixed in the update that we pushed out just now.

Related

Adding buttons next to TextField on Form

I am new to QOOXDOO (like really new). I am enjoying the framework tremendously though, and am busy with a feasibility test for a desktop like app.
I have a straight forward enough Form using a single column render, having test data TextFields like "Account number", "Name", "Cell number". That is working well of course. But I need two small pick list type buttons next to the "Account number" TextField. One for searching by account number, and one for searching by name.
I really don't see how to achieve the positioning of these two buttons?
I am using 5.01 of the framework, but can of course change to 6 if it has a good way of achieving those two pick list buttons I need.
Thanks in advance for any suggestions!
maybe something like this
var doc = this.getRoot();
var form = new qx.ui.form.Form();
var txt1 = new qx.ui.form.TextField("");
form.add(txt1, "Account number", null, "account_number");
var txt2 = new qx.ui.form.TextField("");
form.add(txt2, "Name", null, "name");
var txt3 = new qx.ui.form.TextField("");
form.add(txt3, "Cell number", null, "cell_number");
var s1 = new qx.ui.form.SelectBox();
var s2 = new qx.ui.form.SelectBox();
var formView = new qx.ui.form.renderer.Single(form);
formView._add(s1, {row: 0, column: 2});
formView._add(s2, {row: 0, column: 3});
doc.add(formView, {left: 10, top: 10});

How to use random text in UILocalNotifications?

I'm trying to make an app that will receive local notifications with random text. I used some code but it's not working well. It's coming only "006" or "005", and it won't change.
The code that I used is:
let myArray = ["000", "001", "002", "003", "004", "005", "006"]
let notification = UILocalNotification()
notification.alertBody = myArray[Int(arc4random_uniform(UInt32(myArray.count)))] // text that will be displayed in the notification
notification.fireDate = NSDate() // right now (when notification will be fired)
notification.soundName = UILocalNotificationDefaultSoundName // play default sound
notification.repeatInterval = NSCalendarUnit.NSHourCalendarUnit // this line defines the interval at which the notification will be repeated
UIApplication.sharedApplication().scheduleLocalNotification(notification)
Can you please show me where I made mistake ? Thanks.
What you are doing is correct. Maybe you haven't tried your code enough and had a long string of extreme values.

UI Automation does not find tabPage inside a Tab Control when property Text is provided

I've simplified this problem as much as I can and the code below can be cut&pasted into a 'test.linq' file and loaded into LinqPad. As it stands running this code in LinqPad will show it working - the intention is to find the pane with AutomationId tabPage1 using the UI Automation framework.
Now comment out the working line and bring in the broken line. Now the tab page cannot be found... the only difference is the tab page is declared with a Text property.
I've found a series of blogs which might indicate that the fault lies with an automation provider that the TabControl has but having decompiled the TabControl source I can't see that this is the case but the base Control implements a handler for WM_GETOBJECT and I'm really not sure where that leads.
Any ideas?
<Query Kind="Statements">
<Reference><RuntimeDirectory>\WPF\UIAutomationClient.dll</Reference>
<Reference><RuntimeDirectory>\wpf\UIAutomationProvider.dll</Reference>
<Reference><RuntimeDirectory>\wpf\UIAutomationTypes.dll</Reference>
<Reference><RuntimeDirectory>\Accessibility.dll</Reference>
<Reference><RuntimeDirectory>\wpf\WindowsBase.dll</Reference>
<Reference><RuntimeDirectory>\System.Windows.Forms.dll</Reference>
<Reference><RuntimeDirectory>\System.Security.dll</Reference>
<Reference><RuntimeDirectory>\System.Configuration.dll</Reference>
<Reference><RuntimeDirectory>\System.Deployment.dll</Reference>
<Reference><RuntimeDirectory>\System.Runtime.Serialization.Formatters.Soap.dll</Reference>
<Namespace>System.Windows.Automation</Namespace>
<Namespace>System.Windows.Forms</Namespace>
</Query>
var tabControl = new TabControl();
tabControl.Name = "tabControl";
// Broken
//tabControl.TabPages.Add(new TabPage() { Name = "tabPage1", Text = "First Tab" });
// Working
tabControl.TabPages.Add(new TabPage() { Name = "tabPage1" });
var form = new Form() { Name = "Form1" };
form.Controls.Add(tabControl);
form.Show();
var desktop = AutomationElement.RootElement;
var frmTest = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "Form1"));
var tabPage1 = frmTest.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "tabPage1"));
tabPage1.Dump("tabPage1");

Selenium webdriver- Unable to click on submenu - amazon.in

I am trying to click on a submneu in amazon.in
I could expand the main menu. but can't click on sub menu. I tried two methods. But its showing errors.
Mail category html code:
<li class="nav_pop_li nav_cat nav_divider_before" id="nav_cat_2">Books</li>
Subcategory html
All Books
I used the following methods
Method 1
driver.get("http://amazon.in");
driver.manage().window().maximize();
Actions actions = new Actions(driver);
WebElement moveonmenu = driver.findElement(By.xpath("//li[#id='nav_cat_2']"));
actions.moveToElement(moveonmenu).moveToElement(driver.findElement(By.xpath("//a[#class='nav_a nav_item']"))).click().perform();
Method 2
driver.get("http://amazon.in");
driver.manage().window().maximize();
//locate the menu to hover over using its xpath
WebElement menu = driver.findElement(By.xpath("//li[#id='nav_cat_2']"));
//Initiate mouse action using Actions class
Actions builder = new Actions(driver);
// move the mouse to the earlier identified menu option
builder.moveToElement(menu).build().perform();
// wait for max of 5 seconds before proceeding. This allows sub menu appears properly before trying to click on it
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[#class='nav_a nav_item']"))); // until this submenu is found
//identify menu option from the resulting menu display and click
WebElement menuOption = driver.findElement(By.xpath("//a[#class='nav_a nav_item']"));
menuOption.click();
Please tell me why its not working?
In "Method 1", there was issue with hovering, I guess. Must I say, it was just clicking on the "Main Category" element".
In Method 2", the hovering of "Main Category" is properly happening. The only problem was with the xpath you have chosen to click on the "Sub-Category". The xpath is actually associated with multiple elements. Hence, the code was failing.
Just replace the following codes in your Method 2, it will work:-
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[#class='nav_a nav_item' and .=\"All Books\"]")));
and
WebElement menuOption = driver.findElement(By.xpath("//a[#class='nav_a nav_item' and .=\"All Books\"]"));
Note:- In the above, I have used All Books as the text to be clicked.
( This text must exactly match with what is being displayed in the webpage.)
Similarly, you can replace All Books with other texts such as "Bestsellers, New Releases & Pre-orders, etc."

How to 'shake' a window in qooxdoo?

I'm trying to shake a window, but got error mess in console. My code:
var win = new qx.ui.window.Window ("Login");
win.setLayout (new qx.ui.layout.Grow);
win.add (view);
this.effect = new qx.fx.effect.combination.Shake (
win.getContainerElement ().getDomElement ());
return win;
Where view is a GroupBox instance (from demobrowser/animation/login).
As you have found out by yourself: the DOM element of the window is not there at the moment you create the shake object. In qooxdoo we create all DOM elements at once, so that the browser don't have to render more often than needed.
At the time window fires the "appear" event (you could also use the "resize" event), the DOM element has been created. Be sure to use addListenerOnce() instead of addListener()! Otherwise you will create a new shake effect every time the window gets visible again, if it has been hidden. ;-)
Sorry for noise!
If I create an effect in "appear" listener - code works well.
win.addListener ("appear", function (e)
{
this.effect = new qx.fx.effect.combination.Shake (
win.getContainerElement ().getDomElement ());
}, this);
var win = new qx.ui.window.Window("Login");
win.setLayout(new qx.ui.layout.Grow);
win.add(view);
win.addListener("appear", function(){
var effect = new qx.fx.effect.combination.Shake(win.getContainerElement().getDomElement());
effect.start();
}, this);
return win;

Resources