Welcome, Guest. Please login or register.

Author Topic: Caps lock  (Read 1309 times)

0 Members and 1 Guest are viewing this topic.

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Caps lock
« on: August 04, 2009, 05:39:41 PM »
I noticed there is no Key Code for the caps lock button.  You pretty much have everything but that.  Is there any other cross-platform way to tell if the caps lock key has been pressed?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 27407
    • View Profile
    • SFML's website
    • Email
Caps lock
« Reply #1 on: August 04, 2009, 08:45:25 PM »
Well, caps lock is a modifier which simulates a long press on the shift key. Why would you want to detect presses on this key?
Laurent Gomila - SFML developer

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Caps lock
« Reply #2 on: August 06, 2009, 01:45:49 PM »
Because I'm creating a text input box.  When people press the caps lock key, they expect their text to be capitalized.  If I have no way of detecting if they press it, I have no way of making it behave like the user would expect.

Basically, my reason for wanting this is the same reason that the key exists.

I can do it using win32, but I was hoping for a cross-platform way to do it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 27407
    • View Profile
    • SFML's website
    • Email
Caps lock
« Reply #3 on: August 06, 2009, 01:49:56 PM »
So you think that you can write an algorithm that outputs the proper character according to what keys have been pressed? Well, you can't. Just use the sf::Event::TextEntered event ;)
Laurent Gomila - SFML developer

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Caps lock
« Reply #4 on: August 06, 2009, 09:02:57 PM »
I actually already did it using sf::Input.  It will do any printable key on an American keyboard, whether shifted or not.  The only thing missing is caps lock.  If the caps lock thing isn't possible, it's not possible.

The reason I needed to use Input is to simplify the future use of what I'm making.  I didn't want to have to use an Event and an Input both for the same class.  I opted for complex now to make it simple for people to use later.

And I really didn't mean to sound like an ass earlier.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 27407
    • View Profile
    • SFML's website
    • Email
Caps lock
« Reply #5 on: August 06, 2009, 10:02:37 PM »
I really think you're using the wrong way. Your code will be so complicated, unmaintainable and limited (you'll only be able to handle the ASCII charset -- what about european or asian people?) to emulate a feature which is natively available.

Anyway, caps lock will most likely not be implemented in SFML, sorry ;)

Quote
And I really didn't mean to sound like an ass earlier.

Who said that?
Laurent Gomila - SFML developer

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Caps lock
« Reply #6 on: August 06, 2009, 11:01:40 PM »
I only have one class that takes text input, so it might be worth it.  Can you point me to any examples on how to use a TextEvent.  I can't seem to find anything.  There's really nothing in that section of the Docs.

Thanks for your help.

Edit:

I found your example in this thread.

I wrote about 150 lines of code to do what I could have done in about 6.  Thank you for your help.