官术网_书友最值得收藏!

Setting custom properties

LiveCode's objects come with an impressive number of properties that help us control how they look and function. We can also add our own properties to objects called custom properties. This provides us with a tremendous amount of flexibility.

How to do it...

Follow these steps to set the custom properties:

  1. Create a main stack.
  2. Drag any object onto the stack's card (for example, a button).
  3. Select an object that you wish to add custom properties to.
  4. Right-click on the object and select Property Inspector.
  5. Using the property inspector, select Custom Properties. You should see an interface similar to the one displayed in the following screenshot:
  6. Click on the plus sign to add a new custom property:
  7. Enter a name for the custom property and click on OK. For example, you might want to use a button to represent a book in a game. Add the custom properties, bookTitle, bookYear, bookAuthor, bookPublisher, until your display matches the following screenshot:
  8. Next, we will add content to the custom properties. There are two ways to do this: direct entry and programmatically. We can use the property inspector interface to directly enter the content by selecting the custom property and then typing the content in the Property Contents area (see the following screenshot).
  9. Alternatively, you can add the content to the custom properties via code:
      set the bookPublisher of btn "testButton" to "Packt"

How it works...

We used the property inspector to create custom properties and add content. This content can be changed during an app's execution via code as we demonstrated in step 9.

See also

  • The Getting an object's properties recipe
主站蜘蛛池模板: 萍乡市| 澄城县| 四会市| 崇仁县| 万年县| 林芝县| 江油市| 集贤县| 泰来县| 遵化市| 常德市| 白山市| 肥城市| 滦南县| 阳信县| 永年县| 安仁县| 余姚市| 壶关县| 周宁县| 锦屏县| 阳高县| 万宁市| 黑山县| 特克斯县| 阿荣旗| 确山县| 永嘉县| 富源县| 昭觉县| 印江| 祁阳县| 禹城市| 娄底市| 麻城市| 灵川县| 柏乡县| 社会| 宜君县| 鹿邑县| 新河县|