caret

Set the caret/cursor position to the end of the string value WPF textbox

点点圈 提交于 2019-11-27 07:31:50
I am try to set the caret/cursor position to the end of the string value in my WPF textbox when I open my window for the first time. I use the FocusManager to set the focus on my textbox when my window opens. Nothing seems to work. Any ideas? Note, I am using the MVVM pattern, and I included only a portion of the XAML from my code. <Window FocusManager.FocusedElement="{Binding ElementName=NumberOfDigits}" Height="400" Width="800"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBox

Why 10^1 is 11?

六月ゝ 毕业季﹏ 提交于 2019-11-27 06:42:29
问题 I am currently learning C++ . I was trying to compute power of an integer using the expression: val=10^1; Instead of expected answer 10 , the result was 11 . I have fixed the problem by using pow function of math.h library but I am wondering why this statement is giving me the wrong result. 回答1: Because ^ is the exclusive or operator and not the exponentiation operator. Basically, because the last bit of 10 in binary is 0, by applying exclusive or of 1 the last bit gets converted to 1 because

Custom Caret for WinForms TextBox

时间秒杀一切 提交于 2019-11-27 04:52:53
I'm developing a custom HyperTerminal like application in a WinForms .Net 2.0 application. I have a multiline TextBox in a Panel in which you can interact with a hardware device. My customer wants to have a custom Caret, a filled rectangle the size of one character space instead of the vertical line that is by default. I know .Net does not provide an option to do this by default, but there must some Windows function to do it. Assume a form with a textbox on it: public partial class Form1 : Form { [DllImport("user32.dll")] static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth,

How to override DefaultCaret#setBlinkRate()

走远了吗. 提交于 2019-11-27 04:07:31
问题 I have an problem with Caret, Caret didn't blink without focusGained(see code in Swing Action) to 2nd. JTextField and back to 1st. JTextField how to override DefaultCaret#setBlinkRate() correctly (without override Caret) by default is Caret at the end of Document and blinking on 1st. focusGained tested on win7_32b, Java7.011/025 / Java6 tested with a few Standard L&Fs, custom too, every caused with the same issue please see for more details my answer to question How to retain selected text in

How do I get window.getselection to work for an input type=text field

拟墨画扇 提交于 2019-11-27 03:54:22
问题 I have a contenteditable div, like so: <div id="test" contentEditable="true" style="width: 600px; height:300px;">Lorem ipsum dolor sit amet</div> for which I use the following code: <input type="button" value="Click me" onclick="alert(window.getSelection().focusOffset.toString());"></button> Clicking on the button when I move the caret around in the div, returns to me the actual position (offset) of the caret within the div. The problem is when I replace the contenteditable div with an input

How to avoid cmd.exe interpreting shell special characters like < > ^

♀尐吖头ヾ 提交于 2019-11-27 02:15:04
问题 I have a Windows CMD script that accepts a number of parameters and executes an EXE, passing first some hard-coded arguments and then all of the parameters from the user. The CMD script looks like this: launcher.exe paramX paramY %* The user would execute the CMD script from the Windows shell as follows: launcher.cmd param1 param2 param3 [...] The problem I have is that if the parameters to the CMD script contain shell special characters like < > and ^ , the user is forced to escape these by

Caret character between types rather than variables, surrounded by parentheses

戏子无情 提交于 2019-11-27 02:12:45
I was going through Apple's documentation and I saw something like this (void (^)(void)) . Can somebody explain what this statement means? ^ is XOR, right? void XOR void doesn't makes much sense to me? There was also something like (void (^)(BOOL finished)) Georg Fritzsche These are blocks which add anonymous functions and function objects to Objective-C. See e.g. Introducing Blocks and Grand Central Dispatch : Block objects (informally, “blocks”) are an extension to C, as well as Objective-C and C++, that make it easy for programmers to define self-contained units of work. Blocks are similar

get last character before caret position in javascript

非 Y 不嫁゛ 提交于 2019-11-27 01:55:26
问题 I am about to implement Facebook like in integration in my contenteditable div where if i give '$' and some character like 'a' i need a auto-suggestion which should pop up near my caret position. I need to know how to find out the last character before caret position either in JavaScript for IE and Other browsers. I have access to the Jquery library. (function($) { $.fn.getCursorPosition = function() { var input = this.get(0); if (!input) return; // No (input) element found if (

Javascript: Move caret to last character

感情迁移 提交于 2019-11-26 22:19:27
I have a textarea and when I click in it I want to move the caret to the last character so Something[caret] function moveCaret(){ // Move caret to the last character } <textarea onclick="moveCaret();"> Something </textarea> As I know this is somehow possible with the TextRange object, but I don't really know how to use it EDIT: I would love to see only pure javascript solutions so no libraries please. The following function will work in all major browsers, for both textareas and text inputs: function moveCaretToEnd(el) { if (typeof el.selectionStart == "number") { el.selectionStart = el

How to get selected text/caret position of an input that doesn't have focus?

ぃ、小莉子 提交于 2019-11-26 21:20:59
问题 Is it possible to (reliably) get the selected text/caret position in a input text box if that field doesn't have focus? If not, what's the best way to get and retain this data? Basically, when a user clicks a button I want to insert some text at the caret position. However, as soon as the user clicks that button, the field loses focus and I lose the caret position. 回答1: The following script will hold the caret position and then a button click will insert text at the stored position: