DEV Community

Peter + AI
Peter + AI

Posted on

🎨 Understanding Widget Properties in Uniface 10.4: A Developer's Guide

⚠️ This blog post was created with AI assistance

πŸ“‹ What Are Widget Properties?

Widget properties in Uniface 10.4 control how your user interface elements look and behave. Think of them as the styling and configuration options for buttons, text fields, and other UI components in your application.

The great thing about Uniface is that it gives you multiple ways to set these properties, making your development workflow flexible and efficient! πŸš€

πŸ”§ Three Ways to Set Widget Properties

1. Initialization Files πŸ“„

You can define widget properties in configuration files that your application reads at startup. This is perfect for setting application-wide defaults that apply across all components.

Example: Setting a default font size or color scheme for all text fields in your application.

2. Properties Inspector in the IDE πŸ–±οΈ

The Properties Inspector is a visual tool within the Uniface IDE where you can click and configure widget properties. This is the most user-friendly approach, especially when you're designing your UI layout.

Example: Selecting a button widget and changing its background color directly in the Properties Inspector panel.

3. ProcScript (Programming) πŸ’»

You can set properties dynamically at runtime using ProcScript. This gives you the most control and flexibility, allowing properties to change based on user actions or application state.

Example: Changing a field's color to red when validation fails, or disabling a button when certain conditions aren't met.

🎯 Where Can You Set Properties?

Uniface allows you to set widget properties at different levels:

  • Modeled Entities: Define properties at the data model level
  • Component Templates: Create reusable component patterns with predefined properties
  • Individual Components: Customize specific components
  • Runtime Script: Modify properties on-the-fly during application execution

πŸ”„ The Power of Inheritance

One of Uniface's strongest features is its property inheritance mechanism. This means you can:

  • βœ… Define a common appearance for widgets at a high level
  • βœ… Override specific properties when needed at lower levels
  • βœ… Maintain consistency across your application while allowing flexibility

Uniface uses object inheritance and a defined order of precedence to determine which property value to apply at runtime. This ensures that more specific settings override general ones.

πŸ› οΈ Common Property Functions

Uniface 10.4 provides several built-in functions for working with widget properties:

  • setProperty() - Set a single property value
  • getProperty() - Retrieve a property value
  • setProperties() - Set multiple properties at once
  • getProperties() - Retrieve multiple property values
  • clearProperty() - Remove a property setting
  • clearProperties() - Remove multiple property settings

πŸ’‘ Practical Example Scenario

Imagine you're building a form with multiple input fields. Here's how the inheritance might work:

  1. Initialization File: You set all text fields to use Arial font, size 12
  2. Component Template: You create a template for "required fields" with a light yellow background
  3. Individual Component: You override one specific field to have a white background because it's read-only
  4. Runtime Script: When validation fails, you change the field's border color to red

Each level can override the previous one, giving you precise control! 🎯

⚑ Key Takeaways

  • Widget properties control the appearance and behavior of UI elements
  • You have three main methods: initialization files, IDE Properties Inspector, and ProcScript
  • Properties can be set at multiple levels with inheritance support
  • The inheritance mechanism allows for consistency with flexibility
  • Runtime property modification enables dynamic user interfaces

πŸŽ“ Best Practices

  • Use initialization files for application-wide defaults
  • Leverage component templates for reusable UI patterns
  • Use runtime scripts for dynamic behavior based on user interactions
  • Document your property inheritance hierarchy for team members
  • Test property precedence to ensure the correct values are applied

πŸš€ Ready to style your Uniface application? Start experimenting with widget properties and see how the inheritance system can make your development more efficient!

Happy coding! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

Top comments (0)