Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

"NEW" C++ Technique for Dynamic Tooltips

Featured Replies

[h3]The Old Way[/h3]After actually having truely learned C++, I've been slowly looking more deeply at the many little hints the gauges.h offers us on how to really do things.When making on/off switches, I often want a dynamic tooltip like "Switch: ON".So, I might do this:[PRE]static PCSTRINGZ FSAPI GetState(FLOAT64 number, ID id, PCSTRINGZ string, MODULE_VAR *source_var, PGAUGEHDR gauge){ if (source_var->var_value.n) { return "Starter: ON"; } else { return "Starter: OFF"; }}MOUSE_TOOLTIP_ARGS (Switch_Args) MOUSE_TOOLTIP_ARG(GENERAL_ENGINE1_STARTER, 1, NULL, NULL, value_table, NULL, NULL, GetState)MOUSE_TOOLTIP_ARGS_ENDMOUSE_BEGIN(Switch_rect, HELP_NONE, 0, 0) MOUSE_TOOLTIP_TEXT_STRING ("Switch: %1!s!", Switch_Args) MOUSE_CHILD_FUNCT(10, 10, 21, 21, CURSOR_GRAB, MOUSE_LEFTSINGLE | MOUSE_LEFTRELEASE, Switch_mcb)MOUSE_ENDGAUGE_HEADER_FS700(GAUGE_W, Switch_gauge_name, &switch_list, switch_rect, Switch_cb, 0, 0, 0);[/PRE]You'll note that above I've made GetState return a string, and therefore have made it the STRING_CALLBACK parameter in the MOUSE_TOOLTIP_ARG macro.However, I have always been not quiet happy with it as I am forced to sort of convert the FLOAT64 to a Boolean.[br][h3]And now for something completely different...[/h3]While looking more closely at the MOUSE_TOOLTIP_ARG macro I became curious about the STRING_TABLE parameter. How was this used?The relavent portion of the macro substitution is this: (STRING_TABLE), sizeof(STRING_TABLE)/sizeof(MOUSE_ARG_STRING_MAP),and made me realize that it was a user defined table (array) of MOUSE_ARG_STRING_MAPs!Just above the macro in gauges.h you'll see:[PRE] typedef struct { SINT32 source; PSTRINGZ value; } MOUSE_ARG_STRING_MAP;[/PRE]and tells us that an "entry" is a number that identifies a string. It is defined very much like the FAILURE_RECORD like so:[PRE] MOUSE_ARG_STRING_MAP value_table[] = { { 0, "OFF" }, { 1, "ON" } };[/PRE]My table has only two entries, 0="OFF", 1="ON".GetState can now just return a FLOAT64 like this:[PRE] static FLOAT64 FSAPI GetState(FLOAT64 number, ID id, PCSTRINGZ string, MODULE_VAR *source_var, PGAUGEHDR gauge) { return source_var->var_value.n; }[/PRE]And you then add the STRING_TABLE to the macro and put GetState back in the NUMERIC_CALLBACK parameter like so: MOUSE_TOOLTIP_ARG(GENERAL_ENGINE1_STARTER, 1, NULL, NULL, value_table, GetState, NULL, NULL)and voila! The translation is done by the STRING_TABLE!!!! :-beerchug

  • Author

Hi... looking good, thanks a ton! :-hahHey regarding the failure records, do you know a way to determine something has actually failed...!? I can't seem to retrieve e. g. if NAV1 or NAV2 has failed. There are PP_... TokenVars but they seem to differ from what can be failed in the Failure Dialog of FS.Thanks,Etienne :-wave

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.