New Bug-fix update

:beetle: Fixed Bugs:

  • Copying between documents did send and rebuild all widgets on the clipboard, regardless if the widgets are changed or not. Now only changed/added widgets are send to the WebView/Browser resulting in much faster paste (#1087)
  • Big Sur: fixed “B” after boolean properties in Style insepctor (#1083)
  • Sometimes CSS was wrong for pseudo-states if the container-state was changed in an action (#1079)
  • Fixes for Breakpoints: make sure the right one is used, regardless of the active one in the style-inspector, fix State change for documents with breakoints (#1024)
  • About Box was broken on macOS Mojave (#1077)
  • Change active state did not restore selection on undo/redo (#377)
1 Like

This update introduces a easier way to deal with properties in script-actions. Since Antetype-Cells can contain properties in various states, even the usual case of getting a property for the current state (or the property of a basic cell not part of a widget) was a little bit lengthy.

Getting property values

To get the value of the width-property the call looks like:

// cell is a Antetype-cell from for example targetCells:
let width = cell.valueForKeyInStateWithIdentifier("width", cell.activeStateIdentifier);

now we introduced a new method to make it shorter:

let width = cell.getProperty("width");

with states other than the active one, just add it as parameter. To get the textString-property in a given state now you can use:

let state = … // a state of a widget (Normal, Pressed … 
let text = cell.getProperty("textString", state);

instead of

let text = cell.valueForKeyInStateWithIdentifier("textString", state.identifier);

and similar for

Setting properties

Here setValueForKeyInStateWithIdentifier(value, propertyName, stateIdentifier) can be replaced by setProperty(propertyName, value [,state]) (state is optional, if omitted the active state is used).

cell.setValueForKeyInStateWithIdentifier('foo', 'textString', cell.activeStateIdentifier);
cell.setValueForKeyInStateWithIdentifier('width', 123, pressedState.identifier);


cell.setProperty('textString', 'foo');
cell.setProperty('width', 123, pressedState);  // for a given state

Setting properties an updating the visual representation

As we know simply setting a property does not update the visual representation, you have to use the Antetype.cellSetPropertyInState. Here we added a similar API with optional state-parameter (if omitted the active state is used):

at.cellSetPropertyInState(cell, "width", 345, cell.activeState); 
at.cellSetPropertyInState(cell, "width", 345, anotherState); 

can now be written as:

at.cellSetProperty(cell, "width", 345);
at.cellSetProperty(cell, "width", 345, anotherState);

What do you think, do you like the new way of getting/setting properties?

1 Like