I would like to let user split UITextField when they press enter key in edit mode. Something like:
foo|bar (vertical bar being cursor) - now I press enter
and I'd like to create new UITextField underneath, which should look like this:
foo
bar
But I can't get cursor's position when I press enter. I tried this snippet:
if let selectedRange = field.selectedTextRange {
let cursorPosition = field.offset(from: field.beginningOfDocument, to: selectedRange.start)
print("\(cursorPosition)")
}
But it returns 6 instead of 3. It appears pressing enter will make cursor jump to the end of current word first and then executing my snippet. I tried to put it in textFieldShouldReturn, textFieldShouldEndEditing and also in event of UITextField Did End On Exit with the same results.
Is there a way to prevent the cursor's jump or is there some other way of solving it? I'm a beginner in iPhone development, so I may be missing something obvious...
Related
I'm using hrsh7th/nvim-cmp and some related packages to achieve content completion in nvim
However, in some cases which happen enough times, it becomes very cumbersome to use. Not sure if there's a proper way of doing this or not:
Assume you just typed a word/keyword in your favorite language and you're ready to press ENTER to start a new line. At this time, nvim shows you a dropdown of your choices. I don't want any of those! I'm happy with what I typed.
How can I start my new line without selecting anything from the dropdown menu?
Currently, I have to do either of these two:
press ESC to get rid of the menu. This works but removes me from the Editing mode. Then I have to press o to open a new line and start typing again
press ENTER selecting one of the items in the context menu. Then press ESC to exit editing mode. press X repeatedly to delete what was pasted. Then press o to start a new line!
Here's how I did it:
- ["<CR>"] = cmp.mapping.confirm { select = true },
+ ["<CR>"] = cmp.mapping.confirm { select = false },
So now the default item won't be selected by me pressing Enter. If I wanted the top item I'd be doing a Tab prior to pressing Enter.
I have many hotkeys to navigate chrome very efficiently but they get in the way when I try to type anything anywhere.
Can't figure out how to have autohotkey respond to a textfield being active or to the cursor caret being in effect
I've tried using (!A_CaretX) but I'm not really sure how to.
For example, I want it so when I press "d", it opens a new tab, however when in a text field, I'll probably want key press "d" to output character "d" instead of opening a new tab. Toggleing "suspend mode" through other hotkeys is out of the question.
I also need the hotkeys to go back to working as soon as I'm outside a text field
Before the hotkeys you want to suspend, put #If ( A_Cursor != "IBeam" ). Everything between this line and the next #If will be context-sensitive to whether your mouse cursor state is an IBeam or not.
#If ( A_Cursor != "IBeam" )
[hotkeys you want to be context-sensitive]
#If
[hotkeys you DON'T want to be context-sensitive]
Here are the related items from the help documentation:
A_Cursor (built-in variable containing the type of cursor being displayed)
#If (context-sensitive if)
Note that since this is capturing the mouse's cursor type, you'll need to ensure that the mouse is constantly within the text field when you expect the hotkeys to be suspended. For instance, if you click in a text field but move your mouse off the text area (such that it looks like a regular arrow again) the hotkeys won't be suspended, even though you can type.
Autohotkey Example Needed
Need some help, please. I've searched and can't seem to find an example of what I need.
What I want to do is create a ahk dialog box with a button (I can do this part), and when I click on it, it will type some text into another window. Basically, I want want to offload the "shortcut" to a "mouse click". But, without mapping a shortcut.
Something like this:
When user clicks BOX1, "text" is stored. Then, when user clicks elsewhere, vBOX1 is typed into the cursor location of the window activated by that click
I hope I'm explaining this succinctly. Any help would be appreciated.
Here are two possible alternatives:
First alternative expands #scso's suggestion:
~LButton::
sleep, 200 ;give the window below the cursor some time to get activated
Send, %vBOX1%
return
Now this may seem fine but what it actually does is type the text EVERY time you click the mouse in ANY window. Let's put an additional check so if vBOX1 is empty it doesn't type anything.
~LButton::
sleep, 200 ;give the window below the cursor some time to get activated
If (vBOX1 != "")
{
Send, %vBOX1%
vBOX1 := "" ; clears the contents of vBOX1
}
return
Second alternative:
You use the mouse clicks normally and the text gets typed only when you do Control + Click.
So in order to type the text you need to click once to select the window and then control+click to do the actual typing
~^LButton::
Send, %vBOX1%
vBOX1 := "" ; clears the contents of vBOX1
return
You can expand both alternatives by adding commands for detecting the active window and then typing the text or changing the mouse click combination to something else.
Does anyone know a keyboard shortcut to move your cursor position to highlighted "found" text?
Ex: I press Ctrl+F and type "foo", this will bring me to the first instance of foo in the document.
Now I want a keyboard command to place my cursor next to this instance of foo so I can edit the text that is next to it.
I think I don't get your problem, but that's really much the default behaviour.
Anyway, I recommend incremental find (default keybinding is ctrl+i).
It searches from the current position and the panel is closed afterwards (which is what I want all of the time).
If you press escape in the search bar, the cursor does not move. If you press enter it jumps right to the next occurence.
If you want to put a cursor at each instance of found text in Sublime Text 3
CMD + F to search for text
click the Find All button on the right side of the find bar (bottom right of window)
You should then have an active cursor at the end of each found string of text
On the mac it's command G.Windows, maybe ctrl G?
Am coding am Excel input form in VBA. I have a text box. I want to run a macro, and then get the focus to stay on/return to a text box after hitting enter from within that text box.
I've got the macro to run fine by using _keydown (code=13), but can't get focus to stay in the box. I've tried a setfocus at the end of the macro being called, but to no avail. I'm guessing that the code to move to the next field runs after the keydown detection.
I've searched online for the answer, but can't find anything.
Anyone know how to do this?
Thanks, Chris.
After you catch the keycode, set the keycode to 0, so:
If KeyCode = 13 Then
'do stuff
KeyCode = 0
End If