β¨ This blog post was created with the assistance of AI
When building applications with Uniface 10.4, one of the most important aspects is making your user interface look good and behave correctly. Uniface provides a comprehensive set of properties that let you control how your application components appear to users. Let's dive into how these properties work! π
π What Are UI Styling Properties?
Every visual element in your Uniface applicationβwhether it's a widget, window, label, or frameβhas a collection of properties that control its appearance and visual behavior. Think of these properties as the styling tools that help you create an attractive and user-friendly interface.
For example, you can control:
- Background colors π¨
- Window appearance in desktop applications π₯οΈ
- How fields display (as edit boxes, checkboxes, or grids) βοΈ
- Layout and positioning π
π Static vs. Dynamic Properties
Understanding the difference between static and dynamic properties is crucial for effective development:
Static Properties
Static properties are set in stone once your component is created. You define them during development, and they cannot be changed while the application is running. Think of them as permanent settings.
Dynamic Properties
Dynamic properties are flexible! You can change them on-the-fly using ProcScript or JavaScript after the component has been created. This allows you to create interactive and responsive user interfaces.
Example: You could start with a button that has a blue background, but change it to red when a user makes an error:
$properties(SUBMIT_BUTTON) = "backcolor=red"
βοΈ How Uniface Determines Property Values
Uniface uses a smart priority system to figure out which property value to apply at runtime. This is called the "order of precedence," and it works like a hierarchy from highest to lowest priority:
- Dynamic Script Values π― - Values set in ProcScript or JavaScript (highest priority)
- Instantiation Script Values π - Values set during component creation
- Declarative Values ποΈ - Values set in the Properties Inspector
- Inherited Values π¨βπ©βπ§ - Values inherited from parent objects
- Initialization File Values βοΈ - Values defined in configuration files
- Platform Defaults π₯οΈ - Default values from the technology platform (lowest priority)
Example: If you set a field's background color to "lightblue" in the Properties Inspector, but then change it to "yellow" in ProcScript, the field will be yellow because script values have higher priority! π
π Understanding Property Names
Each property has two names:
- Technical Name (Literal Name): Used in scripts and configuration files. Example:
clientsyntaxcheck
- Display Name: A user-friendly name shown in the Properties Inspector. Example: "Syntax Check in Browser"
Good news! Property names are not case-sensitive. This means clientsyntaxcheck
, ClientSyntaxCheck
, and CLIENTSYNTAXCHECK
all work the same way. π
π Platform-Specific Behavior
The effect of properties can vary depending on where your application runs:
- Web Applications π: Properties can be influenced by CSS, and Dynamic Server Pages (DSP) provide full support for changing properties dynamically
- Desktop Applications π»: Window properties let you control form and shell window appearances
- Mobile Applications π±: Properties adapt to mobile-specific UI patterns
- Character-Based Applications β¨οΈ: Limited but functional property support
π Best Practices
Here are some tips for working with UI styling properties:
- Use Inheritance Wisely πͺ: Properties can be inherited from parent objects. Set common properties at the entity or component level to avoid repetition
- Plan for Flexibility π§: Use dynamic properties when you need to change the UI based on user actions or application state
- Test Across Platforms π§ͺ: If your application runs on multiple platforms (web, desktop, mobile), test how properties behave on each
- Document Your Settings π: Keep track of which properties are set where, especially when using multiple configuration methods
π‘ Practical Example
Let's say you're building a form with a customer address field. You want the field to have a light gray background by default, but turn light green when the user enters valid data:
; Set default color in Properties Inspector
; backcolor=lightgray
; In your validation trigger:
if (valid_address)
$properties(ADDRESS_FIELD) = "backcolor=lightgreen"
else
$properties(ADDRESS_FIELD) = "backcolor=lightpink"
endif
This simple example shows how dynamic properties can provide immediate visual feedback to users! β
π― Conclusion
Understanding UI styling properties in Uniface 10.4 is essential for creating professional, user-friendly applications. By mastering the difference between static and dynamic properties, understanding the order of precedence, and knowing how to set properties in different ways, you can build interfaces that are both attractive and functional.
Remember: the key to effective UI styling is understanding your options and choosing the right approach for your specific needs. Whether you're setting properties declaratively in the IDE or dynamically in code, Uniface gives you the flexibility to create exactly the user experience you want! π
Happy coding! π¨βπ»π©βπ»
Top comments (0)