Jump to content
dragonzhang

How to create a new Widget with a button?

Recommended Posts

hi:

my LCD size is 240x320。

when uGFX power on,I created a Widget  with only two buttons。

When a user clicks on different buttons, there will be different Widget (full screen).

but,I dont`t know how to create a new Widget with a button click event!

 

tks

 

 

Share this post


Link to post
Share on other sites

Well, just call gwinXxxCreate() to create your widget when you receive the button press/release event.

However, this is usually bad practice. When you have enough resources (mainly talking about RAM) you create all the widgets you need during startup/initialization and then you just use gwinShow() and gwinHide() to display the widgets correctly. The handling of touch inputs and so on is all handled through the GWIN visibility and enabled state.

Share this post


Link to post
Share on other sites

tks!

I used Menu sample code! 

when i create new Widget , label can`t display on lcd.

if i mask "gwinLabelSetAttribute(ghLabelLcdBlTime, 100, ""); " ,the label can show .  

GWidgetInit wi; // Apply some default values for GWIN    
gwinWidgetClearInit(&wi);    
wi.g.show = TRUE;    // Create the IP label    
wi.g.width = 200; 
wi.g.height = 20; 
wi.g.x = 10, 
wi.g.y = 100;    
wi.text = "192.168.1.42";    
ghLabelLcdBlTime = gwinLabelCreate(0, &wi); 
gwinLabelSetAttribute(ghLabelLcdBlTime, 100, "");   

 

Share this post


Link to post
Share on other sites

create all the widgets during startup/initialization .

    ghTabset            = gwinTabsetCreate(0, &wi, GWIN_TABSET_BORDER);
    ghPgSetting            = gwinTabsetAddTab(ghTabset, "tab1", FALSE);
    ghPgVersion            = gwinTabsetAddTab(ghTabset, "tab2", FALSE);

I want to show tab1 only, tab2 hide. but can`t work use follow code.

gwinShow(ghPgSetting);
gwinHide(ghPgVersion);

Share this post


Link to post
Share on other sites

When using the tabset widget you should use the tabset widget high level API. There's gwinTabsetSetTab() for that. There are more goodies that you can find in the API documentation.

Share this post


Link to post
Share on other sites
Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×