π€ This blog post was created with the help of AI
If you're working with Uniface 10.4, you'll quickly discover that controlling how your application looks and behaves is all about widget properties. Let me break down the different ways you can set these properties and why this flexibility matters.
π What Are Widget Properties?
Widget properties control the appearance and behavior of UI elements in your Uniface application. Think of them as settings that define things like colors, sizes, fonts, and other visual characteristics of your interface components.
π§ Three Ways to Set Widget Properties
Uniface gives you three main approaches to configure widget properties:
1. Initialization Files π
You can define properties in configuration files that your application reads at startup. This is great for setting default values across your entire application.
2. Properties Inspector in the IDE π₯οΈ
The visual approach! Use the Properties Inspector within the Uniface IDE to set properties directly while designing your components. This is the most intuitive method for developers who prefer visual tools.
3. ProcScript (Runtime) π»
Set or change properties dynamically using script code while your application is running. This gives you the most flexibility and allows your application to adapt based on user actions or data conditions.
ποΈ Where Can You Define Properties?
Uniface offers multiple levels where you can define widget properties:
- Modeled Entities: Define properties at the data model level
- Component Templates: Create reusable templates with predefined properties
- Components: Set properties directly in individual components
- Script: Modify properties dynamically at runtime
π― The Inheritance Mechanism
Here's where Uniface gets really clever! The system uses an inheritance mechanism that allows you to:
- Define a common appearance for widgets at a high level
- Override those settings when needed at more specific levels
- Maintain consistency while keeping flexibility
Uniface follows a defined order of precedence to determine which property value to use at runtime. This means you can set a general rule and then make exceptions where necessary without breaking your overall design.
π Example: Setting a Button Color
Let's say you want all buttons in your application to be blue, but one specific button should be red:
- Initialization File: Set default button color to blue for the entire application
- Component Level: The special button inherits the blue color
- Script Override: Use ProcScript to change that specific button to red when needed
The inheritance system ensures the red color overrides the default blue for that one button, while all other buttons remain blue.
π οΈ Key Functions for Working with Properties
Uniface provides several built-in functions to work with widget properties in your scripts:
-
$properties
- Access component properties -
$fieldproperties
- Work with field-level properties -
$entityproperties
- Handle entity properties -
getProperty()
- Retrieve a specific property value -
setProperty()
- Change a property value -
clearProperty()
- Remove a property setting
π‘ Why This Matters
This flexible property system means you can:
- β Maintain consistent UI design across your application
- β Make quick global changes through initialization files
- β Customize specific components when needed
- β Create dynamic, responsive interfaces that adapt to user needs
- β Reduce code duplication by using inheritance
π Best Practices
When working with widget properties in Uniface 10.4:
- Start with initialization files for application-wide defaults
- Use the Properties Inspector for visual design work
- Reserve scripting for dynamic, runtime changes
- Document your property inheritance strategy
- Test how property values resolve at runtime
π Conclusion
Understanding widget properties and their inheritance mechanism is essential for building maintainable Uniface applications. The three-way approach (initialization files, IDE, and script) combined with multiple definition levels gives you the power to create consistent yet flexible user interfaces.
Whether you're building a simple form or a complex enterprise application, mastering widget properties will make your development work smoother and your applications more professional.
Happy coding! π¨βπ»π©βπ»
Top comments (0)