Does TextField fireDoneEvent() to call stopEditing() in order to close the virtual keyyboard? - textfield

I can close the virtualkeyboard from a button by calling textField.stopEditing. However, I would have expecting setting a DoneListener to close the virtualkeyboard as well when "Search" or "Go" is pressed.
The DoneListener does fire and the code is executed, but the virtualkeyboard remains open. I've tried adding a stopEditing to the DoneListerer, even placing stopEditing callSerially.

I just tried this on my Android OPO device and it worked as expected. The second field did nothing but the first folded the keyboard like a champ:
Form hi = new Form("TextTest", BoxLayout.y());
TextField other = new TextField("");
TextField ttt = new TextField("");
hi.add(ttt).add(other);
ttt.setDoneListener(e -> {
hi.add(ttt.getText());
hi.getContentPane().animateLayout(200);
});
hi.show();

Related

appcelerator how close the window of index from another window

everyone
I am using titanium with alloy, I have two windows which are index.js and main.js.
The window of index.js will be opened when the app run, there is a button in index, main will be opened if someone click the button. Main have another button which is used to close the index.
As you see, I am trying to close index window in main window.
Everything works fine in IOS, but when I test it in Android, I found a strange problem: when I click the button in main.js to close index window, all windows(both of index and main) are closed.
I tried many methods, like use Ti.APP.trigger/Ti.APP.addEventListener and send $.index or a callback function to main.js.
Could anyone help me, thanks.
in index.js use this
$.index.exitOnClose = false
Your solution is to set this property : exitOnClose = false as answered by #genocsb. It's available only on Android.
Actually, this property tells that which window should close the app upon closing the window itself. So, by default, the very first window has the its property exitOnClose = true.
In your case, do something like this:
- index.js
Alloy.Globals.Index = $.index;
Alloy.Globals.Index.open();
// If you will do this and press back button on index screen, then you will land to splash screen.
// Alloy.Globals.Index.exitOnClose = false;
- main.js
$.button.addEventListener('click', function (){
$.main.exitOnClose = true; // setting it to true will cause your app to close from main.xml screen on back button press
Alloy.Globals.Index.exitOnClose = false; // setting it to false here will ensure that you will not land to splash screen if back button is pressed.
Alloy.Globals.Index.close();
Alloy.Globals.Index = null;
});

Sweetalert confirm button breaks input fields

I have a strange bug when I use an input field on a sweet alert I can't have the cursor inside my input field here is a jsfiddle.
https://jsfiddle.net/gvzwu5st/
If I include
showConfirmButton: false
Then it works fine here is the fiddle
https://jsfiddle.net/16L4sddt/
When you have showConfirmButton: true, the openModal() function (line 653) gives focus to the confirm button (line 662):
$okButton.focus();
When you try to click in the input field, the handleOnBlur() function (line 396) is called because the confirm button loses the focus. The functions defines the $targetElement variable which refers to the confirm button (line 397). Skipping some lines... the function will loop through each button of the modal to check if it is the element that got the focus. In your case, the target element is the input field, so it is not any of the buttons. The variable btnIndex keeps the value -1. Lines 413-416:
if (btnIndex === -1) {
// Something in the dom, but not a visible button. Focus back on the button.
$targetElement.focus();
}
So the confirm button ($targetElement) is given back the focus, which prevents the input field from ever receiving it.

How to hide a button on an app with multiple windows? - Objective C OSX

I have an application which has a button on the first window, once pressed this button should hide and perform an action, to hide the button i'm using this code:
[self.myButton setHidden:TRUE];
This works fine until I have multiple windows - new instances of this window do not have this button it's hidden by default. However when I create a new window and press the myButton on the first window it doesn't hide the button.
Furthermore if I create a new window and then close that window and press the myButton on the first and now only window it crashes.
It's clear it always seems to target the last window created, how can I make it always target the first window created, or the window the action is actually being sent from?
New windows are simply being created by calling a newDocument from the document controller like so:
[dc newDocument:self];
Most button actions look like this:
- (void)someAction:(NSButton* sender) {}
or
func someAction(sender : NSButton) {}
As you can see, a sender is passed with the action. Now this sender is actually the button you pressed. So you can simply hide this particular button by calling sender.hidden = true;
The sender is automatically added when you use Storyboards or Xibs to add the actions.
If you add the action programmatically, add a colon after the selector (ObjC) or string (Swift). The button instance should be passed to you then.
... action:#selector(someAction:)...
or
... action:"someAction:" ...

on(release) {...} or myButton.onRelease = function() {...} - action script 2 issues

I am having real confusion with some flash banners I'm creating and making the button into a clickable object which opens a web page.
I have been using this code for a while below, which works...
on(release){
getURL("http://www.the-dude.co.uk", "_blank");
}
And I placed this code on actual button within the actions panel
However I have been told the code above is very old and that I should use action script like below...
buttonInstance.onRelease = function() {
getURL("http://www.the-dude.co.uk", "_blank");
}
So I've tried to get this method below to work but nothing happens when I click the button, and I get one error, this...
So in a nutshell I cannot get this newer code to work! Ahh
Can anyone please help me understand where I am going wrong?
I have tried placing the new code in the Scene 1 of my actions. No worky..
And I've also tried placing the code below, actually on my button within the actions panel...
this.onRelease = function() {
getURL("http://www.the-dude.co.uk", "_blank");
}
Still not working.
My scene settings are alway this...
Any help would be great thanks.
You need to place the code below on the same timeline as the instance of the button (as you tried). And the instancename of the button must be "buttonInstance".
You can set the instance name in the properties panel when the button is selected.
buttonInstance.onRelease = function() {
getURL("http://www.the-dude.co.uk", "_blank");
}

Dojo OnKeyPress Handler: TextBox value is blank

I have a Dojo form that does not contain a submit button. Instead, I added an onkeypress handler to calls a method when Enter is pressed. The problem I am having is that when I hit enter before blurring off the current field, the _process method thinks that field is empty.
Or in other words: type in field1. hit tab. type in field2. hit enter. field2 is blank unless i click off the field or shift-tab back.
Any ideas?
dojo.connect(dijit.byId("fkrform"),"onKeyPress",function(e) {
if (e.keyCode == dojo.keys.ENTER) {
_process();
}
and the method it calls:
function _process()
{
var field1 = dijit.byId("field1").value;
var field2 = dijit.byId("field2").value;
alert(username);
alert(password);
...do stuff...
}
The fields are of dojoType: dijit.form.TextBox, and the form is: dijit.form.Form
Use dijit.byId('field1').get('value') instead of directly try to access the property "value". In your example you saved the value in the variable field1 and field2 and in the alert you use the variable username and password could be the answer why you don't get anything. But you still should use the get method to get a property instead of directly access the property.
When you press "Enter" your form will submit. So you need to connect to the "onSubmit" event on the form, instead of onkeyPress or onKeyUp.
The first example i created prints the value of the input box on every key someone pressed in the console.
http://jsfiddle.net/a8FHg/
But what you really wanted was hooking into the submit. I modified the example. The new example connects to "onSubmit" and creates an alert box with the text of the user input.
http://jsfiddle.net/a8FHg/1/
For completness if jsfiddle doesn't work some day. You JavaScript should looks like this.
dojo.ready(function(){
var form = dijit.byId('form');
var box = dijit.byId('box');
var submit = function(event) {
dojo.stopEvent(event);
alert("User input was " + box.get('value'));
};
dojo.connect(form, 'onSubmit', submit);
});
Assuming your form in your HTML has the id form and your box have the id box.