Set cursor position in Edit Text android - android-edittext

How can i set the cursor position in android edit text? Im making a button which would make the cursor one character forward ie. an arrow key like

You can length of the string entered in edit text.
editText.setSelection(editText.getText().length());

You have to use setSelection(int position) method of edittext.
Like edt.setSelection(0)

Related

How to move cursor in Xcode smoothly?

For example like below gif
First he is type QL1("") and his cursor's position is locate after double quotes
Then how to move cursor's position between double quotes?
I know i can use arrow key,but i don't want to move my hand on keyboard
So is there have convenient way to move cursor?
Just like we can press Tab to move cursor to different parameter
You don't need to do anything. Xcode is already automatically putting that.
Just put a single double quote(")
Write whatever you want to write
Press the next arrow key (->) and the second single double quote(") will be automatically added.
Hope this helps!

Write text in OpenLayers3

I need to write some text in openLayers 3... Not a label, something like a text object, that I can select and drag around the map. This text must have multiple lines.
I tried to use a point with ol.style.text, but it isn't multiline.
I also tried the popups, but I need the text to be always displayed.
Is there any way to use a text feature for this (ol.format.TextFeature)?
Is there any object that I can use for that purpose?
Thanks!!
You can use an ol.Overlay for that. An overlay is basically anything an Element can be. It has a position an positioning that can be set at any time.
See an example: http://openlayers.org/en/v3.9.0/examples/overlay.html?q=overlay
You could use map browser events (pointerdown, pointerup) and if the target is your overlay element then you could move it around and update its position.

Code input text field

Is there a native UI control for code input text field, for example like Whatsapp:
No. To achieve this, they're almost certainly tapping into the textField:shouldChangeCharactersInRange:replacementString: method for their UITextField, selectively accepting and formatting user input to match the dash-if-empty approach.
Further, I'm sure they've subclassed the field; per your comments there isn't a blue cursor - which isn't standard for a UITextField.
No there isn't. Use a UITextField, fill it with dashes, keep track of how many characters the user has entered, and replace the dashes accordingly as the user types.
There's a 4-digit code input text field called CodeInputView written in Swift.
In the past I've added a UITextField to the view and set its hidden == true. Then I show/hide the keyboard by calling becomeFirstResponder()/resignFirstResponder() on it. I listen for text did change notifications and update a visible label with the value of the hidden text field.

Insert string at cursor position of UITextField

I've got a few UITextFields in an UITableView. The user should be able to insert only numbers and dots. To do this, I set the keyboard type to UIKeyboardTypeNumberPad and added a '.'-Button at the bottom left corner. Every time the button is pressed, a function is called. This function should insert a dot at the current cursor position, but this is the problem: UITextField hasn't got an selectedRange property, so I'm not able to get the current cursor position. Does anybody know how to solve this problem or is there any other way to do this? Thanks.
I've finally found a solution for this problem! You can put the text you need inserted into the system pasteboard and then paste it at the current cursor position:
[myTextField paste:self]
I found the solution on this person's blog:
http://dev.ragfield.com/2009/09/insert-text-at-current-cursor-location.html
The paste functionality is OS V3.0 specific, but I've tested it and it works fine for me with a custom keyboard.
Update: As per Jasarien's comment below, it is good practice to save off the pasteboard contents first and restore them afterward. For convenience, here is my code:
// Get a reference to the system pasteboard
UIPasteboard* lPasteBoard = [UIPasteboard generalPasteboard];
// Save the current pasteboard contents so we can restore them later
NSArray* lPasteBoardItems = [lPasteBoard.items copy];
// Update the system pasteboard with my string
lPasteBoard.string = #"-";
// Paste the pasteboard contents at current cursor location
[myUIField paste:self];
// Restore original pasteboard contents
lPasteBoard.items = lPasteBoardItems;
[lPasteBoardItems release];
- (void)insertText:(NSString *)text
available in iOS 3.2 and later.
In Swift
This inserts text at the current cursor position.
textField.insertText("Hello")
My full answer about working with the cursor position is here.
There is now a fantastic number pad type keyboard that includes a decimal point, no configuration necessary except setting (not in IB, not an option there yet) the UITextField's keyboardType property to UIKeyboardStyleDecimalPad, like so:
textField.keyboardType = UIKeyboardTypeDecimalPad;
This does all the fancy stuff you've been trying to do automatically.
If you're looking to create text fields that allow you to enter decimal places may I suggest that you rather fix the decimal point to a certain precision and allow the user to enter numbers as follows:
Assuming your precision is 2 decimal points:
start: value is 0.00
user enters 1: value is 0.01
user enters 2: value is 0.12
user enters 3: value is 1.23
user enters 4: value is 12.34
See What is the best way to enter numeric values with decimal points? for a similar solution for currency.
It is by far a more simple solution than creating a custom keyboard and dealing with all the nuances that that approach presents. If, however, you need variable length precision then that approach might suite you better.
Read the value of the text field as a string when your button is pressed. Edit the string and then set the value of the field to the new string.

How do you add a superscript character into a Powerbuilder textbox?

Is there any way to do this in the Powerbuilder properties window for a datawindow's textbox?
That kind of depends on how you define "textbox", but in general the only way to mix normal and superscript text is with a richtext control. In PB 11.5, you can even use richtext as a column style.
Good luck,
Terry.
Yes. For the text control, you must select a font that has superscript characters (Arial does).
Go into the Windows Character Map (usually in the start menu under Accessories->System Tools) and select your font.
Then go to the superscript character that you want to place in your text control. Click it and then click the Select button to place it down in the character map text box.
Then click the Copy button.
Now you can return to PowerBuilder and paste this value into the properties window text area.
As long as the same font is selected for the DataWindow control as was selected in the character map it should show as your superscript character.
This same techinque can be done to include any of the Wingding type characters as well.
We ended up using two separate text fields. It's a butt-ugly solution, but it works. The superscript field has a smaller font and is nudged a little higher up.
I think newer PB versions support superscripts.
Thanks for the help.
Glenn
If you go to the character map - when you select your character it will show the keys to enter this character on the bottom right of the window.
Example : in Arial font - the ® (registered) mark is Alt + 0174
To enter these, turn your numlock on, hold the alt key down, and type 0 1 7 & 4 then let up on the alt key. You have to use the number keys on the number pad to do this the ones on the top of the keyboard dont work.
You can then enter your characters directly or do something like this :
ls_key = '®'
Actually I stumbled across a simpler solution. I copied and pasted a portion of the text from a pdf into the text property of a datawindow text contol. The superscript character simply pasted in. So I'm guessing that Dougman's solution would work too.
Example:
"™Trademark used under..."
Note: I'm using PB 9.0.1
Thanks for all the help,
Glenn

Resources