EGUI: Changing text colour of a menu entry and changing icon "on-the-fly"?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

EGUI: Changing text colour of a menu entry and changing icon "on-the-fly"?

1,023 Views
DiBosco
Contributor III

Folks,

I have a menu with several items in it. As I scroll through it, the selected (focus?) position sets that line as black text on a white back ground rather than white text on a black background - which is fine. However, I would like, when the user hits enter, for that particular menu entry to have red text as it will be the selected menu item. Then as focus changes, the text will always be red, but the background will change between white and black.

The setting of the focus seems to be done in some fairly complex looking code in:

static void D4D_MenuOnDraw(D4D_MESSAGE* pMsg)

I could add some extra code to this to do what I want. I don't really want to go hacking that if I can avoid it.

So, can I actually do what I want to? Ideally, I suppose, I'd like an API call along the lines of:

SetMenuTextColour(D4D_MENU* pMenu, D4D_MENU_INDEX index, struct D4D_CLR_SCHEME_S *ColourScheme);

So, I would pass a pointer to my menu, which entry on the screen should be highlighted and which colour scheme should be used. As far as I can tell -and I could well be completely wrong - in the normal colour scheme, you can only have two text colours: highlighted and non-highlighted.

Is this at all possible? If so, would someone be able to give me a pointer as to how to do it?

Also, in a similar way, if I have a screen with some entries on it that are declared with a little icon, is it possible to change the icon as the user selects something on the screen? I suppose it's a little like have a check box and indeed, doing it with a check box would also be acceptable I guess.

Many thanks. :smileyhappy:

Labels (1)
0 Kudos
1 Reply

574 Views
DiBosco
Contributor III

No idea whether this is a legitimate way to solve this, but I have hacked the source code a bit and made it work. To me, it looked like the pMenu->pData->item_select variable wasn't working properly, so I have changed routines in d4d_menu.c:

static void D4D_MenuFocusNextItem(D4D_OBJECT* pThis)

static void D4D_MenuFocusPreviousItem(D4D_OBJECT* pThis)

and

static void D4D_MenuOnDraw(D4D_MESSAGE* pMsg)

I couldn't fathom, at all, what was going on with this sort of line:

pMenu->pData->item_select = -1;

Made no sense to me at all, so I have removed all those and now, when you hit enter,  pMenu->pData->ix is stored in  pMenu->pData->item_select and is not changed to these weird -2 and -1 values. I've attached the file. It might be of use to people, I might have fixed an old bug or I might have completely broken something. Hard to say, the code is so poorly commented.

0 Kudos