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
- 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
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 ..
Then in the macro you can set individual properties as visible or not, writable or not ...
using a sim icon, and the listed functions ...
Hope that helps
Leigh
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 ..
Then in the macro you can set individual properties as visible or not, writable or not ...
using a sim icon, and the listed functions ...
Hope that helps
Leigh
-
- 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
Thank you Leigh!
I will try it out hopefully tomorrow and I will let you know how it goes.
I will try it out hopefully tomorrow and I will let you know how it goes.
-
- 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
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?
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?
- 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
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 ...
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
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 ...
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
-
- 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
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?
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?
-
- 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
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!
And you were right, the cosmetic name does not work, it must be used the variable name.
Thank you for your help!