Re: Entering text backwards
- From: "David" <David@xxxxxxxxxxxxx>
- Date: Thu, 12 May 2005 06:03:21 -0700
Thanks. I'm always surprised by what turns out to be easy, and what is
difficult or impossible. I really thought there would just be some sort of
setting that I could set, and it would just work.
Unfortunately, the solution is not workable for my particular problem. I'm
trying to enter Canaanite text, but really I'm trying to do more than that.
The program is for linguists. I'm trying to enter text in any language the
user decides upon, which might include all sorts of "dead languages" like
Canannite, along with constructed languages, like Tolkein's languages or
Klingon.
The variation in text, keyboards, and font mappings prevent me from doing
anything that maps specific characters.
"durstin" wrote:
> There may be some clever cultural trick available, but you could handle the
> keypress event and do your own string construction, something along the
> following. You would probably want to create your own subclassed textbox
> control:
>
> private void textBox1_KeyPress(object sender,
> System.Windows.Forms.KeyPressEventArgs e)
>
> {
>
> TextBox txtBox = (TextBox) sender;
>
> string text = txtBox.Text;
>
> int selectionStart = txtBox.SelectionStart;
>
>
> // Alphanumerics
>
> if (33 <= e.KeyChar && e.KeyChar <= 122)
>
> {
>
> if (txtBox.SelectionStart == 0)
>
> text = e.KeyChar + text;
>
> else
>
> {
>
> text = text.Substring(0, selectionStart) + e.KeyChar +
> text.Substring(selectionStart , text.Length - selectionStart);
>
> }
>
> e.Handled = true;
>
> }
>
>
> // Backspace -- treat as Delete
>
> // unless some text is selected, in which case it behaves as normal
>
> else if (e.KeyChar == 8 && txtBox.SelectionLength == 0 && selectionStart <
> text.Length)
>
> {
>
> text = text.Remove(selectionStart, 1);
>
> e.Handled = true;
>
> }
>
>
> // Delete -- doesn't get captured by KeyPress
>
> txtBox.Text = text;
>
> // return character entry point to original location
>
> txtBox.SelectionStart = selectionStart;
>
> }
>
>
>
> "David" <David@xxxxxxxxxxxxx> wrote in message
> news:16E43C83-AF2B-4A18-A2D8-AFAA9C58BF42@xxxxxxxxxxxxxxxx
> > I want to enter text in a textbox, but have it appear right to left. I
> want
> > to keep the English cultural settings to do it. When I select RightToLeft
> =
> > yes, and TextAlign=left, the text ends up right aligned. The entry cursor
> > appears to the left of previously entered text, but when I actually type
> the
> > text, it is entered on the right side.
> >
> > (I'm actually not trying to enter English text. I'm trying to enter
> > Canaanite text. But since the operating system doesn't recognize
> Canaanite
> > as a cultural setting, I am keeping the English setting, and using a font
> > that maps English characters to Canaanite glyphs. So what I'm really
> trying
> > to do is to have the text behave as if I were entering Hebrew, but since
> the
> > font maps to the ascii characters, I can't change to Hebrew settings,
> because
> > I want the keyboard mapping to remain unchanged.)
>
>
>
.
- References:
- Entering text backwards
- From: David
- Re: Entering text backwards
- From: durstin
- Entering text backwards
- Prev by Date: Re: How to unselect a combobox ???
- Next by Date: DataGrid: Lock a column
- Previous by thread: Re: Entering text backwards
- Next by thread: Multi-coloured text in a winform application
- Index(es):
Relevant Pages
|
|