Text box with line wrapping

The contents of this answer were merged into mpl master in https://github.com/matplotlib/matplotlib/pull/4342 and will be in the next feature release. Wow… This is a thorny problem… (And it exposes a lot of limitations in matplotlib’s text rendering…) This should (i.m.o.) be something that matplotlib has built-in, but it doesn’t. There have been a few threads … Read more

C# wait for user to finish typing in a Text Box

I define “finished typing” now as “user has typed something but has not typed anything after a certain time”. Having that as a definition i wrote a little class that derives from TextBox to extend it by a DelayedTextChanged event. I do not ensure that is complete and bug free but it satisfied a small … Read more

How to change disabled background color of TextBox in WPF

Unfortunately for the TextBox control, it appears like it’s not as simple as just adding a trigger and changing the Background color when the trigger condition is true. You have to override the entire ControlTemplate to achieve this. Below is one example on how you might do this: <Window x:Class=”StackOverflow.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”MainWindow” Height=”350″ Width=”525″> … Read more

How do I implement a TextBox that displays “Type here”?

Something that has worked for me: this.waterMarkActive = true; this.textBox.ForeColor = Color.Gray; this.textBox.Text = “Type here”; this.textBox.GotFocus += (source, e) => { if (this.waterMarkActive) { this.waterMarkActive = false; this.textBox.Text = “”; this.textBox.ForeColor = Color.Black; } }; this.textBox.LostFocus += (source, e) => { if (!this.waterMarkActive && string.IsNullOrEmpty(this.textBox.Text)) { this.waterMarkActive = true; this.textBox.Text = “Type here”; this.textBox.ForeColor … Read more

Get current cursor position in a textbox

It looks OK apart from the space in your ID attribute, which is not valid, and the fact that you’re replacing the value of your input before checking the selection. function textbox() { var ctl = document.getElementById(‘Javascript_example’); var startPos = ctl.selectionStart; var endPos = ctl.selectionEnd; alert(startPos + “, ” + endPos); } <input id=”Javascript_example” name=”one” … Read more