SDK Question Changing MFD buttons

Goth

Occasional orbinaut
Donator
Joined
Aug 1, 2008
Messages
424
Reaction score
2
Points
0
It's not possible to change the name of the MFD buttons real-time, is it?
This is why we see something like
Code:
Prv <
Nxt <
+   <
-   <
in IMFD for example: a workaround.
For what I guess, the function char *MFD::ButtonLabel (int bt) is called by Orbiter only when the MFD it's loaded.
Indeed I tried something like this:
Code:
// Return button labels
char *MFD::ButtonLabel (int bt)
{
    // The labels for the buttons used by our MFD mode
    char *label[NButtons] = { //not "static char" but just "char"
        "B1","B2","B3","B4","B5","B6","B7","B8","B9"
    };
    if(changeButton) //an example boolean variable
        strcpy(label[0],"New"); //this changes the button
    return (bt < NButtons ? label[bt] : 0);
}
and it works only if I change the variable "changeButton" at the constructor of the MFD class, so it's useless.

So my question is: why this is not allowed by the SDK?
If there isn't any particular reason I do a request for it ^^

Thanks for reading.
 
Last edited:
Yes, there is a way. oapiRefreshMFDButtons() function should do the trick.:thumbup:

Edit: IMFD is using MFD::InvalidateButtons() function to update the button labels.
 
Last edited:
Oh, thanks for the answer, I will try this function.
Edit: IMFD is using MFD::InvalidateButtons() function to update the button labels.
Your MFD do not update the labels. :blink:
Or you mean "to update what the buttons do"?
 
Your MFD do not update the labels. :blink:
It do update the labels but first you need to turn on the "GlassCockbitMode" from the configuration page. I don't remenber why it was disabled by default.
 
Ah! Just tried. :lol:
Actually this could be set by default.
 
The source code in Precession MFD uses 2-D arrays to simplify button maintenance.
 
Back
Top