"Highlighting" Text in a menu?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

"Highlighting" Text in a menu?

Post by XianForce »

Well let's say I had a menu and when the mouse hovered over it, the text was to change to a different color.

How would I go about doing that? I was thinking I'd create two colors, and then have it check each option to see if the mouse is hovering over it... But something tells me there's a better way to do it, so is there a better way to do it than individually checking each option, and then setting its color?
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: "Highlighting" Text in a menu?

Post by MarauderIIC »

Just treat it like collision detection, but with mouse coordinates. So I guess that while there is a more efficient implementation, that one should do fine.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: "Highlighting" Text in a menu?

Post by XianForce »

MarauderIIC wrote:Just treat it like collision detection, but with mouse coordinates. So I guess that while there is a more efficient implementation, that one should do fine.
One of these days... I'll find something better.... >.>
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: "Highlighting" Text in a menu?

Post by XianForce »

Wait... Now that I think about it, I'd have to re-render the text every frame... And that means I'd have to keep deleting the text I rendered... There's no function... or maybe a different text library, where I can do something like "set_color()" ?
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: "Highlighting" Text in a menu?

Post by MarauderIIC »

XianForce wrote:Wait... Now that I think about it, I'd have to re-render the text every frame...
Well, no, not really. Just re-render when mouse is over it but it wasn't last frame, and re-render when mouse isn't over it but it was last frame.
And you can always draw on top of it without erasing it.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: "Highlighting" Text in a menu?

Post by XianForce »

MarauderIIC wrote:
XianForce wrote:Wait... Now that I think about it, I'd have to re-render the text every frame...
Well, no, not really. Just re-render when mouse is over it but it wasn't last frame, and re-render when mouse isn't over it but it was last frame.
And you can always draw on top of it without erasing it.
oh yeah... cause creating the SDL_Surface* allocates the memory, not the text rendering...
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: "Highlighting" Text in a menu?

Post by MarauderIIC »

XianForce wrote:oh yeah... cause creating the SDL_Surface* allocates the memory, not the text rendering...
I'm not sure if you're being sarcastic (in which case we're misunderstanding each other's problem/solution) or not :)
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: "Highlighting" Text in a menu?

Post by dandymcgee »

MarauderIIC wrote:
XianForce wrote:oh yeah... cause creating the SDL_Surface* allocates the memory, not the text rendering...
I'm not sure if you're being sarcastic (in which case we're misunderstanding each other's problem/solution) or not :)
I'm pretty sure he was just agreeing with your solution. Didn't seem very sarcastic to me. :)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: "Highlighting" Text in a menu?

Post by XianForce »

MarauderIIC wrote:
XianForce wrote:oh yeah... cause creating the SDL_Surface* allocates the memory, not the text rendering...
I'm not sure if you're being sarcastic (in which case we're misunderstanding each other's problem/solution) or not :)
nope, I'm not being sarcastic (I've learned computers suck at sarcasm... so I try not to use it xD)
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: "Highlighting" Text in a menu?

Post by eatcomics »

If it's sarcasm you should put one of these :roll: at the end... Example:
"Yeah, everybody loves Raymond is the best comedy on tv :roll: "
Image
Post Reply