Textbox do not accept accentuation
Last post 06-10-2008 11:46 AM by Mark Rideout. 19 replies.
Sort Posts:
03-05-2008 8:21 PM
Textbox do not accept accentuation

Silverlight is amazing!

The TextBox is not accepting accentuation.

Thanks.

Vítor

Sincorde

Loading...
Joined on 03-04-2008
Posts 14
03-05-2008 8:26 PM
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'

Microsoft SDET
Visual Web Developer Team
Silverlight Tools for VS

jamlew

Loading...
Joined on 09-21-2007
Bellevue, WA
Posts 213
03-05-2008 8:28 PM
Re: Textbox do not accept accentuation

Yes

 Sorry for my English.

 Vítor

Sincorde

Loading...
Joined on 03-04-2008
Posts 14
03-06-2008 12:42 PM
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'

Microsoft SDET
Visual Web Developer Team
Silverlight Tools for VS

jamlew

Loading...
Joined on 09-21-2007
Bellevue, WA
Posts 213
03-06-2008 1:11 PM
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

Loading...
Joined on 08-29-2007
Mexico
Posts 14
03-06-2008 1:35 PM
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

Manuel Ruiz

Loading...
Joined on 08-29-2007
Mexico
Posts 14
03-06-2008 1:43 PM
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'

Microsoft SDET
Visual Web Developer Team
Silverlight Tools for VS

jamlew

Loading...
Joined on 09-21-2007
Bellevue, WA
Posts 213
03-07-2008 12:38 AM
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.

m.wawrusch

Loading...
Joined on 12-15-2007
Posts 13
03-07-2008 8:23 AM
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!

 

andrewboni

Loading...
Joined on 03-07-2008
Posts 1
04-08-2008 9:48 PM
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!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,315
04-10-2008 7:01 AM
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

Loading...
Joined on 07-19-2007
Lisboa, Portugal
Posts 29
04-10-2008 7:35 PM
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??

Bigsby

Loading...
Joined on 07-19-2007
Lisboa, Portugal
Posts 29
04-10-2008 10:30 PM
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!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,315
04-11-2008 3:45 AM
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

Loading...
Joined on 04-06-2008
Posts 32
04-11-2008 4:14 AM
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 ;-)
 

LooneyLynn

Loading...
Joined on 04-06-2008
Posts 32
04-11-2008 10:12 AM
Re: Re: Re: Textbox do not accept accentuation

That's great.

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

 

Thanks

Bigsby

Loading...
Joined on 07-19-2007
Lisboa, Portugal
Posts 29
05-30-2008 9:30 PM
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?

Bigsby

Loading...
Joined on 07-19-2007
Lisboa, Portugal
Posts 29
05-31-2008 9:03 AM
Re: Re: Re: Textbox do not accept accentuation

Bigsby

Can you check the link please?

Thanks

Vítor

Sincorde

Loading...
Joined on 03-04-2008
Posts 14
06-02-2008 4:29 AM
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.

Bigsby

Loading...
Joined on 07-19-2007
Lisboa, Portugal
Posts 29
06-10-2008 11:46 AM
Marked as Answer
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"

 

Mark Rideout

Loading...
Joined on 01-03-2006
Redmond, WA
Posts 235
Page view counter