SFML community forums

Help => Window => Topic started by: texus on March 31, 2012, 07:57:15 pm

Title: TextEntered event not sent on backspace/delete on mac
Post by: texus on March 31, 2012, 07:57:15 pm
When pressing the backspace or delete key I don't get TextEntered events on Mac OS X Lion.
I do get KeyPressed events, so it is not a big issue.

Example code:
while (App.isOpen())
{
    sf::Event event;
    while (App.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            App.close();
           
        if (event.type == sf::Event::TextEntered)
        {
            if (event.text.unicode == 8) // 8 = backspace
            {
                // The program never passes here
            }
            else if (event.text.unicode == 127) // 127 = delete
            {
                // Neither does is pass here
            }
        }
       
        if (event.type == sf::Event::KeyPressed)
        {
            if (event.key.code == sf::Keyboard::Back)
            {
                // This works
            }
            else if (event.key.code == sf::Keyboard::Delete)
            {
                // This also works
            }
       }
    }
           
    App.clear();
    App.display();
}
 

Is this a problem with sfml or is it just mac os x that isn't sending those events?
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: eXpl0it3r on March 31, 2012, 08:08:37 pm
Didn't even know that there's a TextEntered event.
Technically delete and backspace do not enter any text, they remove text.
For example you could also create a textbox that can't delete anything, so delte or backspace wouldn't change the text and in your sense wouldn't enter any text. ;)
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: Laurent on March 31, 2012, 08:22:04 pm
If backspace and delete exist in the Unicode standard (I think they do), they could technically be triggered as TextEvent. I think that other OSes do it.
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: texus on March 31, 2012, 08:56:42 pm
The other OS's do trigger the TextEvent (at least Linux does, but Windows probably too).
So it's just a problem in mac.
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: Hiura on April 01, 2012, 07:27:25 pm
Can you open an issue on github about this ? I'll try to fix that later this month.
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: texus on April 01, 2012, 08:05:49 pm
I opened the issue: https://github.com/SFML/SFML/issues/192
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: Hiura on April 22, 2012, 04:56:58 pm
I'm starting to wonder if Apple did something weird with their keyboard.. On my macbook pro 5.1 when I press the backspace alone I get unicode 127, which should be bound to delete. And when I press the backspace with fn held down, which produce delete, I get unicode 63272 which belongs to the "Private Use Area" (http://www.unicode.org/charts/#symbols).

What kind of keyboard are you using ? Do you get the same unicode values ? (You can use key codes (http://itunes.apple.com/ch/app/key-codes/id414568915?l=en&mt=12) app.)
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: texus on April 29, 2012, 02:22:17 pm
I am afraid I can't help you very much as I installed my mac on a pc and I don't use a mac keyboard.
I do get unicode 127 for every combination: only backspace, command + backspace, control + backspace, option + backspace and shift + backspace.

According to my mac I am using the ISO (European) keyboard (in real I am using a Belgian keyboard).
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: Hiura on April 29, 2012, 03:55:36 pm
Well, if anyone with OS X on a Mac want to test it I would be grateful.  :)
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: Hiura on May 19, 2012, 09:14:01 pm
No one ? C'mon it juste take a few minutes.  ;)


I'm starting to wonder if Apple did something weird with their keyboard.. On my macbook pro 5.1 when I press the backspace alone I get unicode 127, which should be bound to delete. And when I press the backspace with fn held down, which produce delete, I get unicode 63272 which belongs to the "Private Use Area" (http://www.unicode.org/charts/#symbols).

What kind of keyboard are you using ? Do you get the same unicode values ? (You can use key codes (http://itunes.apple.com/ch/app/key-codes/id414568915?l=en&mt=12) app.)

Thanks
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: Ceylo on May 20, 2012, 12:14:12 am
Code: [Select]
Key Down
Characters: 
Unicode: 127 / 0x7f
Keys:
Key Code: 51 / 0x33
Modifiers: 256 / 0x100

Key Down
Characters:
Unicode: 63272 / 0xf728
Keys:
Key Code: 117 / 0x75
Modifiers: 8388864 / 0x800100

On a French keyboard (MBP 8.1). First one is backspace and second one is Fn + backspace.
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: Hiura on May 20, 2012, 09:57:03 am
Thanks a lot Ceylo!

We have the exact same result so I guess Apple's engineer did something wrong with the unicode values. I'll convert these two keys to their correct unicode value in sf::Event::TextEntered then.

If someone find any other key bound to some weird unicode value let me know.
Title: Re: TextEntered event not sent on backspace/delete on mac
Post by: Kamiz on August 19, 2013, 02:09:13 pm
Pressing Delete (ASCII 127) doesn't send TextEntered event. Pressing Backspace (ASCII 8 ) does.
(SFML 2.1, Windows 7 x64)