Two strings on one button?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Two strings on one button?

    We have buttons on a screen. The buttons are bitmaps. So far so good.

    We’d like to place on these buttons two different text strings, at different locations and with different fonts.

    Specifically: we want a fixed string with small font as a button label (eg. “minutes”) and another string, with larger font, representing some variable value, eg. “15”.

    The Button widget API supports a text label (via BUTTON_SetText) and that works fine. That gives us one of the two desired strings.

    The question is: what’s the best (or proper) way to add the second string?

    I’m having partial success using the TEXT widget for this purpose, but this appears to be causing another issue, to wit: the TEXT widget seems to be interfering with the touch zone of the button underneath it.

    Is there a better way to do this?

    Thanks for any light you’re able to shed on this matter!
  • Hello Rafeb,

    Sorry for the delay. There are 2 possibilties, to do this.

    1) Assuming the TEXT widget was created as a child window of the button, just make it pass touch events on to the parent window.

    2) Without using further widgets use a custom callback function for the button and do the following:

    C Source Code

    1. ...
    2. case WM_PAINT:
    3. BUTTON_Callback(pMsg);
    4. //
    5. // Displaying the 2nd text here will make it appear on top of the BUTTON widget.
    6. //
    7. break;
    8. ...

    In both ways a custom callback function is needed. For detailed information on how to implement a callback function, please have a look at the chapters "The Window Manager" and "Window Objects (Widgets)" in the emWin documentation.
    If you have any further questions, please let me know.

    Best regards,

    Edit: The WM_POST_PAINT message is not intended to perform drawing operations. It is just to enable the application to know when the drawing process of a window finished. The background is that one drawing process might take an unspecified number of WM_PAINT messages. Therefor the Window Manager sends a WM_PRE_PAINT and a WM_POST_PAINT message before and after a drawing process.

    The post was edited 1 time, last by SEGGER - Adrian ().