Custom Callback with Button

  • Hi,

    The goal is to create a button with Multi strings where the strings have different fonts from each other, So as suggested by emwin documentation I have created a custom callback function but I observe that the custom callback is overwriting all the previous set properties. The codes are as follows

    Code
    hButton = WM_GetDialogItem(pMsg->hWin, ID_BUTTON1);
    WM_SetCallback(hButton , CallBack_Button);
    
    
    hButton = WM_GetDialogItem(pMsg->hWin, ID_BUTTON1);
    BUTTON_SetBkColor(hButton, BUTTON_CI_UNPRESSED, SKY_BLUE);
    BUTTON_SetBkColor(hButton, BUTTON_CI_PRESSED, HEADER_OFFWHITE);
    BUTTON_SetTextColor(hButton, BUTTON_CI_PRESSED, BASE_BLUE);
    BUTTON_SetTextColor(hButton, BUTTON_CI_UNPRESSED, BASE_BLUE);


    the callback function

    the result would be that
    the entire OFF_WHITE background is replaced by white color except for the two strings. Is there any method where the button_<routines> can be used along with custom modifications.

    Thanks

    Edited 2 times, last by Suresh (April 5, 2023 at 1:08 PM).

  • Hi,

    With the default skin of the BUTTON widget the functions BUTTON_SetBkColor() and BUTTON_SetTextColor() are not working. Either set the classic skin or use SKINFLEX properties to change properties like colors.

    If you overwrite the callback function of a widget you can call the default callback function (e.g BUTTON_Callback()) and then draw something.

    Here is a brief example how this could be done:


    Best regards,
    Sven

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!