Making DW Radio Buttons and Check Boxes look disabled
An effective GUI quickly communicates to the users how they can interact with the current window. For most datawindow edit styles, PowerBuilder supplies its developers with the means to visually show if it is available to accept user input. Unfortunately, if you are working with an older version of PB, how to show a disabled check box or a radio button is a puzzle. Here is how I deal with this issue.
Below is a datawindow from one of my company’s applications written in PB 7.0 . The Edit and dddw edit styles indicate its protected status with its background color: white for enabled, buttonface for disabled. The radio button and checkbox edit styles do not have this option. In order to find out if the column is enabled or not, the user must actually click on it and see if changes.
The radio button and check boxes all appear to be enabled
My solution is to use the 3D look for enabled radio buttons and check boxes. When a radio button or check box is disabled, I switch the object to 2D. So the datawindow changes to look like this:
Disabled items now appear in 2D
This does the job of clearly communicating to the user that the radio button “Weight Verify Physical Pallet” and the check boxes “Taxable” and “Newspaper” are disabled, while the other two check boxes are available to be selected and changed.
To achieve this 2D disable look in script, you can use modify script similar to the following:
Another way to achieve this result is to borrow the technique discribed in the post The Ol’ Hidden Items in the dddw Part II. This method also deals with tabular datawindow styles where multiple rows are displayed and the radio buttons and check boxes may be enabled in some rows, and disabled in others.
In this method, for each radio button or check box edit style, the datawindow has two copies of each of these columns. One copy would not be protected and have the enabled 3d look, the other would be protected with the disabled 2D look. The disabled copy would sit directly under the enabled copy. Use a datawindow expression to determine the protect property and reuse this expression for the visibility property. When the column is enabled, the visibility property of the enabled column would be turned on, and the visibility property of the disabled would be turned off. When the column should be disabled, the visibility properties of the two copies would be reversed. Voila!
Another option is to upgrade to 11.5 which fixes this issue.
On a side note, pressing the space bar is the keyboard shortcut to toggle a check box with focus.
Hello. But what about a datawindow showing some records which one field is a raddio button with only one value to choose? For example a survey with multi-optional questions: a question could have 4, 5, or more options to choose ( every option text is a record in a database table), and once an option is selected, the others options in the same question should be deselected automatically. How to include a raddiobutton style but only with one display value: Y? Thanks in advance.
DataWindow is one of the most inconsistent objects in PowerBuilder. Disappointingly, there are no dynamic expressions for these attributes (Edit attributes and many others including DisplayOnly) even though implementing dynamic expressions for almost each attribute by Sybase should be a piece of cake. What is the point of having dynamic expressions for Color attributes when we cannot set a column’s DisplayOnly with a dynamic expression as well? We end up with a HYBRID code – dynamic expression for color and hand-coded logic for DisplayOnly. Really? Other inconsistencies – Protect instead of Enabled, ReadOnly (with dynamic expression), etc are not exposed in Properties, DW.Color and DW.Gradient.Color do not have dynamic expressions while object.Color and object.Gradient.Color do. DW Buttons are a joke – they act like text objects with a 3D border – insonsistent focus rectangle, no space-bar support, etc. Seriously?
Over the years of being a PowerBuilder developer, I have recorded many things I have learned and I may need to refer to in the future. Some of these discoveries date back to PowerBuilder 4 and may not be relavent with the later versions of PB
I am still in the process of transferring all my notes. (Hey, I have other things to do)