Book a Demo

Author Topic: Shape Script: Override setfillcolor  (Read 5093 times)

skelesp

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Shape Script: Override setfillcolor
« on: August 26, 2013, 10:53:28 pm »
Hi

I've made a shape script in which I change the default color depending on the value of a tagged value.

Code: [Select]
if(hastag("taskType","Semi-Automatic"))
      {
            setfillcolor(255, 173, 91);
      }

The downside is that I'm not able to change the color of this object using the UI. Is there a way to change the color manually after the shape script has set the color?

Thanks!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Shape Script: Override setfillcolor
« Reply #1 on: August 26, 2013, 11:55:28 pm »
I guess he only way is to add another tag that, when existent, suppresses the code part you posted.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Shape Script: Override setfillcolor
« Reply #2 on: August 27, 2013, 09:14:14 am »
If you use that to color the entire element then you can not override it via the UI. The correct way to use SetFillColor is to color a section of the shape (as opposed to the whole thing.) This uses the color without removing the ability of the user to customize the display.

A special case of this is that if you're calling DrawNativeShape then EA knows that the color is being used for the entire element and will allow it to be overridden by the diagram local color.

skelesp

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Shape Script: Override setfillcolor
« Reply #3 on: August 27, 2013, 10:14:24 pm »
Could you show me what I need to adopt in the following code to make it work?

Code: [Select]
shape main
{
      layouttype="border";
      
      if(hasTag("triggeredByEvent","true"))
      {
            setlinestyle("dot");
      }
      defsize(110,60);
      startpath();
      roundrect(0,0,100,100,10,10);
      endpath();
      
      if(hastag("taskType","Semi-Automatic"))
      {
            setfillcolor(255, 173, 91);
      }
...
« Last Edit: August 27, 2013, 10:14:50 pm by skelesp »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Shape Script: Override setfillcolor
« Reply #4 on: August 28, 2013, 09:17:37 am »
I assume what you haven't included is a fillandstrokepath().

If you want your conditional script colour to be overridden by users the only way to do it is to replace your path with a call to drawnativeshape(). As long as you're using an activity, state or action you'll still get the round rect.