Disable fields in Component Properties

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Disable fields in Component Properties

Post by viki2000 »

This is a general question about situations when we make a new component.
I have chosen as particular example the SSD1306 I2C display.
How do you set the Properties of the component, when you create the component, to be able to disable/enable fields based on what we choose in a list of a previous field?
Look at the screenshot below and please tell me how you do that:
Disable fields in Component Properties
Disable fields in Component Properties
Disable fields in Component Properties.jpg (100.57 KiB) Viewed 5722 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Disable fields in Component Properties

Post by LeighM »

Hi,
First create a property change event macro, see the EV section, click on "Property" to create a macro that runs when a property value changes ..
ev_property.jpg
ev_property.jpg (27.41 KiB) Viewed 5719 times
Then in the macro you can set individual properties as visible or not, writable or not ...
visible.jpg
visible.jpg (55.15 KiB) Viewed 5719 times
using a sim icon, and the listed functions ...
sim_icon.jpg
sim_icon.jpg (88.97 KiB) Viewed 5719 times
Hope that helps
Leigh

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: Disable fields in Component Properties

Post by viki2000 »

Thank you Leigh!
I will try it out hopefully tomorrow and I will let you know how it goes.

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: Disable fields in Component Properties

Post by viki2000 »

A little bit more help is welcome.
I started to look at the quadrature encoder possible improvements and I use the source code provided here:
http://www.matrixtsl.com/mmforums/viewt ... =7&t=19676
Below is my trial component that does not work now.
I tried to add the event property change macro, the decision and the set visible function as you recommended, but it does not work. I think I make mistakes how I set up the things.
What I want is this: when I choose the property field Debouncing with OFF, then I want the Repeat Rate to become disabled.
Could you help on this particular example?
QuadEnc2a.fcfx
(32.61 KiB) Downloaded 221 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Disable fields in Component Properties

Post by LeighM »

Hi,
The EV_Property_Change macro was the wrong type for the event.
So I've created a new one, EV_Property.

Just check that you create the macro by double clicking EV->Property,
then in the Add Event dialog click Macro->Add new
then OK & Edit macro

A correct macro is shown as attached to the event by an icon ...
ev_property.jpg
ev_property.jpg (49.54 KiB) Viewed 5699 times
Also I think that the property variable names have to be used rather than the "cosmetic" title names, but I could be wrong, I've not checked that.

Hope that helps
Leigh
Attachments
QuadEnc2a.fcfx
(33.79 KiB) Downloaded 188 times

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: Disable fields in Component Properties

Post by viki2000 »

I did exactly what you did, only that I named the macro Ev_Property_Change as I have seen in your first screenshots above.
Now in the last code proposed by you – it works! – I have seen that you named the macro it Ev_Property.
But it should not matter.
I checked one more time my initial code and I found the problem.
I played with “fire”.
So, in my initial code the macro was listed under incompatible macros, that’s why did not work.
And it was listed there because I changed the return to nothing and you let it Long.
I went back to my initial code with macro named Ev_Property_Change, I changed the Return to Long and it works too!
What’s happening now: when I choose the Debouncing OFF, then the Repeat Rate property disappears completely, it is not to be seen anymore.

What other property can I choose to make it visible but disabled, I guess not writable, as in my first screenshot example with SSD1306 display?

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: Disable fields in Component Properties

Post by viki2000 »

A short double check confirms my guess: the SetWritable instead of SetVisible makes exactly what I wanted.
And you were right, the cosmetic name does not work, it must be used the variable name.
Thank you for your help!

Post Reply