Skip to main content

Microsoft Silverlight

Answered Question Textbox do not accept accentuationRSS Feed

(0)

Sincorde
Sincorde

Member

Member

45 points

21 Posts

Textbox do not accept accentuation

Silverlight is amazing!

The TextBox is not accepting accentuation.

Thanks.

Vítor

jamlew
jamlew

Contributor

Contributor

2856 points

435 Posts

Microsoft

Re: Textbox do not accept accentuation

What do you mean?  You mean it's not accepting accented characters, like 'é'?

---------
If this post has solved your problem, please select 'Mark as answer'

- Jimmy Lewis
Microsoft SDET
Visual Web Developer Team

Sincorde
Sincorde

Member

Member

45 points

21 Posts

Re: Textbox do not accept accentuation

Yes

 Sorry for my English.

 Vítor

jamlew
jamlew

Contributor

Contributor

2856 points

435 Posts

Microsoft

Re: Textbox do not accept accentuation

Can you post your XAML?  I made a quick SL app with a textblock and a textbox, and it worked great.

---------
If this post has solved your problem, please select 'Mark as answer'

- Jimmy Lewis
Microsoft SDET
Visual Web Developer Team

Manuel Ruiz
Manuel Ruiz

Member

Member

28 points

14 Posts

Re: Textbox do not accept accentuation

Hi!

I'm having the same problem... and I think it has nothing to do with XAML but with the OS and / or Keyboard configuration... I'm using Vista Ultimate in Spanish with keyboard configured in Spanish - Mexico... I'm looking forward to test it int XP Pro English - Keyboard Spanish International sort... I'll keep you informed.

 Regards

Manuel Ruiz
X-Stream Networks
Developer

Manuel Ruiz
Manuel Ruiz

Member

Member

28 points

14 Posts

Re: Textbox do not accept accentuation

I've made the test on XP Pro English - Keyboard Spanish International... and got the same problem... I also noticed that key's related to Alt Gr are not working either.

Manuel Ruiz
X-Stream Networks
Developer

jamlew
jamlew

Contributor

Contributor

2856 points

435 Posts

Microsoft

Re: Textbox do not accept accentuation

Ah yes, I'm seeing it.  I was copying from the character map the first time, which does work, but I added the Spanish (Int'l Sort) keyboard and it looks like using the Ctrl+', <letter> input doesn't work.  It also looks like if you just type ' or " into a textbox it inputs twice.  Thanks for pointing the issue out.

---------
If this post has solved your problem, please select 'Mark as answer'

- Jimmy Lewis
Microsoft SDET
Visual Web Developer Team

m.wawrusch
m.wawrusch

Member

Member

20 points

15 Posts

Re: Textbox do not accept accentuation

I hope that you guys understand the severity of this bug. Without Alt-Gr support users will not be able to enter email adresses in german speaking countries (100mil population) as @ is mapped to Alt-Gr + Q. So please put this on the top of the list for bug fixes.

andrewboni
andrewboni

Member

Member

2 points

1 Posts

Re: Textbox do not accept accentuation

Silverlight is great! 

I'm having the same problem too. It's very serious bug...

Hope that the silverlight team correct it quickly!

 

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP

Re: Textbox do not accept accentuation

Chris created one extended textbox for resolving this issue. Could you guys please test this textbox? http://michaelsync.net/2008/04/07/silverlight-2-beta1-international-non-us-textbox


(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


Bigsby
Bigsby

Member

Member

262 points

81 Posts

Re: Textbox do not accept accentuation

Same here with Silverlight 2 and Portuguese (Portugal) keyboard.

When pressging '~' the TextBox writes '~~' instead of waiting for the next character and write the correspondend accented character like 'ã'.

As sad before, the AltGr key doesn't work, therefore making it impossible to write the character '{', '[', ']', '}', '€', '@' and '£'.

 

I wonder if this is supposed to be a bug or a feature because I had to developed a TextBox form scratch in WPF listening to SYS_CHAR to make something like the Mac TextBox that writes the accented in the selection when it is pressed.

I would love this to be a feature if the pressed character and not KeyboardEventArgs.Key (because the same KeyboardEventArgs have different characters deppending on the Keyboard Layout) was written and I could display the text I want no matter the Keyboard Layout used. Minding all keys and modifiers work.

Bigsby
Bigsby

Member

Member

262 points

81 Posts

Re: Textbox do not accept accentuation

This is not going well.

Michael Sync's proposal is great but the Portuguese keyboard works a little different. As I said before, there isn't a single key for the accented characters, for instance:

In the German keyboard PlatformKeyCode 187 resolve the 'ü';

In the Portuguese keyboard, to write a 'ã', you need to press PlatformKeyCode 191 where lies '~' (nothing happening in text at this time) and then press 'A' Key.

I tried to listenning to the KeyDown event and act according to 191 PlatformKeyCode and display the character but setting the TextBox.Selected property clears all text and displays only the text set for the SelectedText property.

Shall we just wait for the Silverligth 2 Final version??

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP

Re: Textbox do not accept accentuation

Bigsby:
Michael Sync's proposal is great
 

Chris is the one who created this textbox. I like his idea and his sample. So, I'm trying to spread this helpful information with everybody.

Bigsby:
ut the Portuguese keyboard works a little different.
 

Yes. Portuguese keyboard won't be like German Keyboard. So, you probably need to create your own keyboard for that. It's just key-mapping for your font so it might be not so difficult to create one. Chris might write about how to create our custom keyboard in my blog too.

Bigsby:
Shall we just wait for the Silverligth 2 Final version??
 

Yes. it's the best option. Silverlight 2 final version or Silverlight 3 will definitely be better than Silverlight 2 beta.  but sometimes, we can't just wait. so, we are sharing this workaround that we can use before we got some cool from MS.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


LooneyLynn
LooneyLynn

Member

Member

96 points

32 Posts

Re: Re: Textbox do not accept accentuation

Which keyboard do you use???

There is a portuguese and a portuguese brazilian layout... Please tell me your exact layout... I think it is much faster if I just create the layout class as trying to explain how it is done...


regards chris 

LooneyLynn
LooneyLynn

Member

Member

96 points

32 Posts

Re: Re: Re: Textbox do not accept accentuation

The following works for the official portugues keyboard... Have fun...

 

 

 public class Portuguese_Keyboard : TextBoxKeyboard
    {
        #region Windows - Latin char table

        private struct KeyToChar
        {
            public Byte Code;
            public Char Char;
        }

        private KeyToChar[] Default = new KeyToChar[]
            {
                new KeyToChar() { Code = 220, Char='\\'},
                new KeyToChar() { Code = 219, Char='\''},
                new KeyToChar() { Code = 221, Char='«'},
                new KeyToChar() { Code = 187, Char='´'},
                new KeyToChar() { Code = 191, Char='~'},
                new KeyToChar() { Code = 186, Char='+'},
                new KeyToChar() { Code = 222, Char='º'},
                new KeyToChar() { Code = 192, Char='ç'},
                new KeyToChar() { Code = 189, Char='-'},
                new KeyToChar() { Code = 190, Char='.'},
                new KeyToChar() { Code = 188, Char=','},
                new KeyToChar() { Code = 226, Char='<'},
                new KeyToChar() { Code = 106, Char='*'},
                new KeyToChar() { Code = 111, Char='/'},
                new KeyToChar() { Code = 109, Char='-'},
                new KeyToChar() { Code = 107, Char='+'},
            };
        private KeyToChar[] Shifted = new KeyToChar[]
            {
                new KeyToChar() { Code = 220, Char='|'},
                new KeyToChar() { Code = 219, Char='?'},
                new KeyToChar() { Code = 221, Char='»'},
                new KeyToChar() { Code = 187, Char='`'},
                new KeyToChar() { Code = 191, Char='^'},
                new KeyToChar() { Code = 186, Char='*'},
                new KeyToChar() { Code = 222, Char='ª'},
                new KeyToChar() { Code = 192, Char='Ç'},
                new KeyToChar() { Code = 189, Char='_'},
                new KeyToChar() { Code = 190, Char=':'},
                new KeyToChar() { Code = 188, Char=';'},
                new KeyToChar() { Code = 226, Char='>'},

                new KeyToChar() { Code = 48, Char='='},
                new KeyToChar() { Code = 49, Char='!'},
                new KeyToChar() { Code = 50, Char='"'},
                new KeyToChar() { Code = 51, Char='#'},
                new KeyToChar() { Code = 52, Char='$'},
                new KeyToChar() { Code = 53, Char='%'},
                new KeyToChar() { Code = 54, Char='&'},
                new KeyToChar() { Code = 55, Char='/'},
                new KeyToChar() { Code = 56, Char='('},
                new KeyToChar() { Code = 57, Char=')'},
            };
        private KeyToChar[] Alted = new KeyToChar[]
            {
                new KeyToChar() { Code = 50, Char='@'},
                new KeyToChar() { Code = 51, Char='£'},
                new KeyToChar() { Code = 52, Char='§'},
                new KeyToChar() { Code = 55, Char='{'},
                new KeyToChar() { Code = 56, Char='['},
                new KeyToChar() { Code = 57, Char=']'},
                new KeyToChar() { Code = 48, Char='}'},
                new KeyToChar() { Code = 187, Char=']'},
                new KeyToChar() { Code = 69, Char='€'},
                new KeyToChar() { Code = 186, Char='¨'},
            };

        #endregion

        private Boolean m_IsLeftAct = false;
        private Boolean m_IsRightAct = false;
        private Boolean m_IsTopAct = false;
        private Boolean m_IsPointed = false;
        private Boolean m_IsTilde = false;

        public override event KeyEventHandler OnUnknown;

        public override String Description { get { return "Portuguese"; } }

        public override TextBoxKeyboard CreateInstance()
        {
            return new Portuguese_Keyboard();
        }

        public override String HandleKeyDown(Object InSender, KeyEventArgs InArgs)
        {
            // detect and dispatch generic control codes...
            if (base.HandleKeyDown(InSender, InArgs) == null)
                return "";

            // if only Ctrl is down, no char will be displayed...
            if (IsCtrlDown && !IsAltDown)
                return "";

            // handle possible text codes...
            Int32 Code = InArgs.PlatformKeyCode;
            String c = null;

            if (((Code >= 48) && (Code <= 58)) || ((Code >= 65) && (Code <= 90)) || (Code == 32))
                c = Convert.ToChar((Byte)Code).ToString().ToLower();

            if (IsAltDown && IsCtrlDown) // "Alt Gr" key...
            {
                for (int i = 0; i < Alted.Length; i++)
                {
                    if (Alted[ i ].Code == (Int32)Code)
                    {
                        c = Alted[ i ].Char.ToString();

                        break;
                    }
                }
            }
            else if (IsShiftDown)
            {
                for (int i = 0; i < Shifted.Length; i++)
                {
                    if (Shifted[ i ].Code == (Int32)Code)
                    {
                        c = Shifted[ i ].Char.ToString();

                        break;
                    }
                }

                if (c != null)
                    c = c.ToUpper();
            }
            else
            {
                for (int i = 0; i < Default.Length; i++)
                {
                    if (Default[ i ].Code == (Int32)Code)
                    {
                        c = Default[ i ].Char.ToString();

                        break;
                    }
                }
            }

            // check for unrecognized characters...
            if (c == null)
            {
                if (OnUnknown != null)
                    OnUnknown(InSender, InArgs);

                return "";
            }

            if (m_IsRightAct)
            {
                m_IsRightAct = false;

                if (c.Length > 0)
                {
                    switch (c[0])
                    {
                        case ' ': c = "´"; break;
                        case 'e': c = "é"; break;
                        case 'a': c = "á"; break;
                        case 'i': c = "í"; break;
                        case 'o': c = "ó"; break;
                        case 'u': c = "ú"; break;
                        case 'E': c = "É"; break;
                        case 'A': c = "Á"; break;
                        case 'I': c = "Í"; break;
                        case 'O': c = "Ó"; break;
                        case 'U': c = "Ú"; break;
                        default: c = "´" + c; break;
                    }
                }
            }
            else if (m_IsLeftAct)
            {
                m_IsLeftAct = false;

                if (c.Length > 0)
                {
                    switch (c[0])
                    {
                        case ' ': c = "`"; break;
                        case 'e': c = "è"; break;
                        case 'a': c = "à"; break;
                        case 'i': c = "ì"; break;
                        case 'o': c = "ò"; break;
                        case 'u': c = "ù"; break;
                        case 'E': c = "È"; break;
                        case 'A': c = "À"; break;
                        case 'I': c = "Ì"; break;
                        case 'O': c = "Ò"; break;
                        case 'U': c = "Ù"; break;
                        default: c = "`" + c; break;
                    }
                }
            }
            else if (m_IsTopAct)
            {
                m_IsTopAct = false;

                if (c.Length > 0)
                {
                    switch (c[0])
                    {
                        case ' ': c = "^"; break;
                        case 'e': c = "ê"; break;
                        case 'a': c = "â"; break;
                        case 'i': c = "î"; break;
                        case 'o': c = "ô"; break;
                        case 'u': c = "û"; break;
                        case 'E': c = "Ê"; break;
                        case 'A': c = "Â"; break;
                        case 'I': c = "Î"; break;
                        case 'O': c = "Ô"; break;
                        case 'U': c = "Û"; break;
                        default: c = "^" + c; break;
                    }
                }
            }
            else if (m_IsTilde)
            {
                m_IsTilde = false;

                if (c.Length > 0)
                {
                    switch (c[0])
                    {
                        case ' ': c = "~"; break;
                        case 'a': c = "ã"; break;
                        case 'n': c = "ñ"; break;
                        case 'o': c = "õ"; break;
                        case 'A': c = "Ã"; break;
                        case 'N': c = "Ñ"; break;
                        case 'O': c = "Õ"; break;
                        default: c = "~" + c; break;
                    }
                }
            }
            else if (m_IsPointed)
            {
                m_IsPointed = false;

                if (c.Length > 0)
                {
                    switch (c[0])
                    {
                        case ' ': c = "¨"; break;
                        case 'e': c = "ë"; break;
                        case 'a': c = "ä"; break;
                        case 'i': c = "ï"; break;
                        case 'o': c = "ö"; break;
                        case 'u': c = "ü"; break;
                        case 'E': c = "Ë"; break;
                        case 'A': c = "Ä"; break;
                        case 'I': c = "Ï"; break;
                        case 'O': c = "Ö"; break;
                        case 'U': c = "Ü"; break;
                        default: c = "¨" + c; break;
                    }
                }
            }
            else
            {
                if (c == "´")
                {
                    if (!m_IsRightAct)
                        c = "";

                    m_IsRightAct = true;
                }

                if (c == "^")
                {
                    if (!m_IsTopAct)
                        c = "";

                    m_IsTopAct = true;
                }

                if (c == "`")
                {
                    if (!m_IsLeftAct)
                        c = "";

                    m_IsLeftAct = true;
                }

                if (c == "~")
                {
                    if (!m_IsTilde)
                        c = "";

                    m_IsTilde = true;
                }

                if (c == "¨")
                {
                    if (!m_IsPointed)
                        c = "";

                    m_IsPointed = true;
                }
            }

            return c;
        }
    }

 

regards, christoph husse

 

(if this has answered your question please mark as answered ;-)
 

Bigsby
Bigsby

Member

Member

262 points

81 Posts

Re: Re: Re: Textbox do not accept accentuation

That's great.

KeyCode 187 and 186 otherwise it that's just great.

 

Thanks

Bigsby
Bigsby

Member

Member

262 points

81 Posts

Re: Re: Re: Textbox do not accept accentuation

I found a Silverlight TextBox working perfectly with accented characters without any keyboard configuration.

You can check it out for yourselves here.

Is there somthing hidding?

Sincorde
Sincorde

Member

Member

45 points

21 Posts

Re: Re: Re: Textbox do not accept accentuation

Bigsby

Can you check the link please?

Thanks

Vítor

Bigsby
Bigsby

Member

Member

262 points

81 Posts

Re: Re: Re: Textbox do not accept accentuation

Sorry. False alarm.

The link is: http://www.microsoft.com/beta/downloads/

This is, actually, a very clever solution that consists in putting a HTML Element <input type="text"/> "in front" of the Silverlight object. This is a workaround that doesn't permit any thing regarding transforming and animating and makes it very dificult to move the object dynamically. It's a nice try though.

Mark Rideout
Mark Rid...

Contributor

Contributor

2357 points

273 Posts

MicrosoftModerator
Answered Question

Re: Textbox do not accept accentuation

Yes, this is a known bug in both Beta 1 and Beta 2 that we are addressing right now for RTM. I apologize for the inconvenience.

-mark
Silverlight Program Manager
Microsoft
This post is provided "as-is"

 

BernardoCastilho
Bernardo...

Member

Member

4 points

4 Posts

Re: Textbox do not accept accentuation

It's nice that this bug will be fixed soon in the TextBox control, thanks.

But Silverlight should provide a way to convert keystrokes into characters. It could be a KeyPressed event as in WinForms, or a static char GetChar(KeyDownEventArgs e), or even a GetCharacter member in the KeyDownEventArgs class.

Without this, it's almost impossible to figure out reliably whether the user pressed 'A' or 'a' for example (it could be a French keyboard or caps-lock could be on for example).

I have already seen several controls that end up creating a hidden TextBox, giving it the focus, and monitoring the TextChanged event just to figure out what the user wanted to do. Others (as posted above) created long look up tables that are keyboard-specific.

But these are all hacks. The real solution has to be implemented in the platform. A KeyPress event (as in WinForms) would be ideal.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities