Access properties of screen objects from code (designer)

Create amazing UI interfaces with a Visual TFT AI. Focus on your design goals by simply dropping visual elements, and the NECTO studio will generate code for you.
Post Reply
Author
Message
Kelte
Posts: 4
Joined: 22 Dec 2021 17:44

Access properties of screen objects from code (designer)

#1 Post by Kelte » 03 Jan 2022 13:09

Hi,

I'm new with Necto.

I'd like to change properties of screen objects like caption of a label or color.

I've put a label and a button to the designer. Goal is to write meassured data to a caption. But I don't know how do acces the object properties.

I just found the possibilty to change the screen color within the show function. I created an OnClick function to change the color but nothing happens if I push the button. (When I touch the screen, LED RA15 gets darker)

And I can not access other objects then the screendata itself.

main_screen.c

Code: Select all

#include "main_screen.h"
#include "scr_main_screen.h"

static vtft_t *_vtft;

void main_screen_show(vtft_t *vtft)
{
    _vtft = vtft;
    initialize_main_screen();

    // works
    main_screen_data.color = 0xf000; 

    vtft_set_current_screen(_vtft, main_screen.screen_data);
}

void Btn_OnClick()
{
    // doesn't works
    main_screen_data.color = 0x00f0; 
    vtft_set_current_screen(_vtft, main_screen.screen_data);

        
    // undeclared
    Label1.  
    
    // undeclared
    &Button1.width = 30;
}
Board: fusion for PIC32 v8
TFT 3.5" with cap

What I'm doing wrong?

Thanks. Kelte
Attachments
TFT.zip
(7.13 KiB) Downloaded 53 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Access properties of screen objects from code (designer)

#2 Post by filip » 17 Jan 2022 10:34

Hi,

After you change the property, you will have to redraw the screen. Have you tried it ?

Regards,
Filip.

gojdic5678
Posts: 17
Joined: 27 Jan 2022 08:15

Re: Access properties of screen objects from code (designer)

#3 Post by gojdic5678 » 02 Mar 2022 17:31

can you please show the function?
the only place where this is mentioned is in VisualTFT help - Drawing screens and components:
void DrawScreen(TScreen *aScreen);

gojdic5678
Posts: 17
Joined: 27 Jan 2022 08:15

Re: Access properties of screen objects from code (designer)

#4 Post by gojdic5678 » 03 Mar 2022 14:48

so the redraw screen function from mikroSDK is:
vtft_refresh_current_screen(_vtft);

but you didn't answered how to access particular objects, as he tried to access them according to VisualTFT help:
objects_props.png
objects_props.png (29.54 KiB) Viewed 1845 times

if you try to access objects properties via its name created in Designer, you will get:
Undeclared identifier 'Button1' in expression

can you please show how to access objects properties created in Designer? thank you

gojdic5678
Posts: 17
Joined: 27 Jan 2022 08:15

Re: Access properties of screen objects from code (designer)

#5 Post by gojdic5678 » 04 Mar 2022 13:34

ok so it looks like this is the way:
main_screen.Button1 -> text.caption = "Hello";

seen here:
viewtopic.php?f=238&t=77793

Kelte
Posts: 4
Joined: 22 Dec 2021 17:44

Re: Access properties of screen objects from code (designer)

#6 Post by Kelte » 14 Apr 2022 21:58

Hi,

thanks. That helped a lot.

I changed/ added in the main_screen.c:

Code: Select all

void main_screen_show(vtft_t *vtft)
{
    _vtft = vtft;
    initialize_main_screen();
    
    main_screen.Button1 -> text.caption = "Hello";
    
    vtft_set_current_screen(_vtft, main_screen.screen_data);
}

void main_screen_Action_OnClick_Button1()
{
    main_screen.Button1 -> text.caption = "New Hello";

    vtft_draw_component(_vtft, (vtft_component*)(main_screen.Button1));
}
In the designer I added the OnClick action: main_screen_Action_OnClick_Button1.

Now the text of the button is changed on startup and again on cliking the button.

I attached the complete file.

My next step will be the interaction with the main file to display e.g. meassurement result.

Ciao

Kelte
Attachments
TFT3.zip
(8.13 KiB) Downloaded 58 times

Post Reply

Return to “Visual TFT AI”