Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: TextEntered event not sent on backspace/delete on mac  (Read 9102 times)

0 Members and 1 Guest are viewing this topic.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
TextEntered event not sent on backspace/delete on mac
« 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?
TGUI: C++ SFML GUI

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #1 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #2 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.
Laurent Gomila - SFML developer

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #3 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.
TGUI: C++ SFML GUI

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #4 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.
SFML / OS X developer

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #5 on: April 01, 2012, 08:05:49 pm »
TGUI: C++ SFML GUI

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #6 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 app.)
SFML / OS X developer

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #7 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).
TGUI: C++ SFML GUI

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #8 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.  :)
SFML / OS X developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #9 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 app.)

Thanks
SFML / OS X developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #10 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.
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #11 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.
SFML / OS X developer

Kamiz

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: TextEntered event not sent on backspace/delete on mac
« Reply #12 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)

 

anything