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

Author Topic: Editable textboxes and you~  (Read 3458 times)

0 Members and 1 Guest are viewing this topic.

drakelord

  • Newbie
  • *
  • Posts: 22
    • View Profile
Editable textboxes and you~
« on: July 09, 2009, 09:25:12 pm »
This isn't so much of a "I don't know how to do it" thread as it is more of a general discussion thread regarding this subject.

I currently have a textbox, that is selectable, and editable.  This part is cake.  But for the next part, I do not know enough about SFML itself yet to determine the most optimal route.

1)  Displaying the flashing | glyph at the edit point.
The only way I know to do this right now with SFML is to calculate the width of each individual character and how far it is in, and place it inbetween the two characters manually.  Annoying in a way.  

2)  Being able to set an edit point by clicking in the middle of a textbox somewhere.
Once again, this goes back to the previous situation.  I can manually calculate the position on the screen, the width of each character, and determine if the spot is within the string... but it seems like a pain in the arse, ;)

Is there an easier way that this can be done?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Editable textboxes and you~
« Reply #1 on: July 09, 2009, 10:09:41 pm »
You can use sf::String::GetCharacterPos for both problems.
Laurent Gomila - SFML developer

drakelord

  • Newbie
  • *
  • Posts: 22
    • View Profile
Editable textboxes and you~
« Reply #2 on: July 10, 2009, 01:04:41 am »
I'm going to assume that GetCharacterPos() returns the top-left position of the character as other get position functions defaults to?

IE, if I set the string position as 100 px by 60 px, then go to the 3rd character, the returned position will be 100 + some number by 60px?

EDIT:  Also, I see in the documentation that it doesn't not apply scale.  So does that mean if the string is scaled down 50%, that it will still return the position as if it were not scaled at all?

venomj

  • Newbie
  • *
  • Posts: 2
    • View Profile
Editable textboxes and you~
« Reply #3 on: July 10, 2009, 04:47:20 am »
I got the same problems when I made a small gui lib before.
I don't think there's another way around.
You need to do the work yourself.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Editable textboxes and you~
« Reply #4 on: July 10, 2009, 07:40:16 am »
Quote
I'm going to assume that GetCharacterPos() returns the top-left position of the character as other get position functions defaults to?

Probably. Or the left-baseline position, I don't remember :lol:

Quote
IE, if I set the string position as 100 px by 60 px, then go to the 3rd character, the returned position will be 100 + some number by 60px?

EDIT: Also, I see in the documentation that it doesn't not apply scale. So does that mean if the string is scaled down 50%, that it will still return the position as if it were not scaled at all?

The point returned is in local coordinates, and you can easily get global coordinates using String::TransformToGlobal.
Laurent Gomila - SFML developer

Andershizzle

  • Newbie
  • *
  • Posts: 16
    • View Profile
Editable textboxes and you~
« Reply #5 on: September 06, 2009, 08:30:10 pm »
Mind postin up your code for your textbox? :D

 

anything