In TButtonGroup.ButtonOptions what does adding gboGroupStyle do? - delphi

The help indicates that adding gboGroupStyle to the ButtonOptions on a TButtonGroup:
"Specifies that the buttons should inherit the group style that is set on the container."
But this explanation still leaves me lost - any ideas?

The gboGroupStyle option in the TButtonGroup.ButtonOptions property has nothing to do with GroupIndex as it's known e.g. from TSpeedButton.
Setting of the gboGroupStyle option to True allows you to:
set the TButtonGroup.ItemIndex property, so you can predefine which button will be focused as default, nothing cool
click the buttons with ENTER or SPACE keys, what will fire the TGrpButtonItem.OnClick event of the button item (if assigned), perform its action, or fire the TButtonGroup.OnButtonClicked event
I agree the name of this is quite misleading, but that's what I found in the source code from Delphi-XE2.

gboGroupStyle makes the TButtonGroup act as a group - that means, one and only one button is selected at a given time. It is similar to grouping several TSpeedButtons with the GroupIndex, where only one button inside that group is selected at any time. The currently selected button can be read and written via the ItemIndex property of TButtonGroup. To visualize the selected button one can implement an OnBeforeDrawButton or OnDrawButton handler.

From my experimentation it looks like if gboGroupStyle is used then the ItemIndex property can be set to something other than -1, so that the TButtonGroup remembers the last button that was pressed.

Related

Wrapper component for material toggle group (Angular 7)

I'm trying to create a wrapper component for material button-toggle-group. I should add a lot of custom styling for it, so it makes sense to do this in a component so I can import this component later rather than doing it every time. However, I've hit a snag. It is only possible to click the button one time, and then it is checked forever. Also, all buttons can be checked at the same time. What I'm wondering is:
How do I change the selected button when option is selected?
How can I use the boolean in the dataset to set one of the buttons to checked by default?
Also, how can I limit it to one selection at a time? I tried setting the "multiple"-parameter to false, but this does not seem to work.
I have provided what I have so far in a Stackblitz - for some reason this is not loading the material theme properly, but you can still see the problem and what I have so far:
https://stackblitz.com/edit/angular-b7rxxq
A mat-button-toggle-group is intended to be a group of several buttons... because your loop is on the mat-button-toggle-group you are creating two groups each containing one button.
Remove your loop from mat-button-toggle-group
<mat-button-toggle-group (change)="optionSelected($event)" multiple="false" [name]="label">
Add it to the mat-button-toggle so you have a yes and no in one mat-button-toggle-group... also use [checked]="option.value to default the value
<mat-button-toggle i18n="{{option.i18n}}" [value]="option.value" [checked]="option.value" *ngFor="let option of options" style="margin-left:15%">{{option.displayValue}}</mat-button-toggle>
Please Note: once your options are in a single group, only one will ever be selected at a time... once selected you cannot deselect... you will need to do it programmatically if you need the ability to deselect.
Stackblitz
https://stackblitz.com/edit/angular-rmn4k4?embed=1&file=src/app/toggle-wrapper/toggle-wrapper.component.html

VoiceOver : is 'accessibilityActivationPoint' really useful?

I tried and understood what could be the purpose of the accessibilityActivationPoint but in vain.
When a focused accessible element is activated, that property should indicate VoiceOver the specific area it's going to activate when a user double-taps the element (Apple reference) : for me, it's always the selected element itself.
I understood the selected element is considered as a block by VoiceOver, whatever the other elements inside. Once a double tap occurs to activate this block, VoiceOver calls accessibilityActivate to know what to perform (Apple reference).
1/. I've written many tests by creating a custom view including a switch control. Whatever the value of accessibilityActivationPoint inside (or outside on another switch control), the value of the switch control never changes. Is it a proper use case or am I totally wrong ?
2/. When we gather many elements inside one accessible element, how is VoiceOver able to activate one of them while they aren't accessible by definition ? Pointing one of them thanks to the accessibilityActivationPoint should work ?
Personally, I couldn't make it work and think that I'm really confusing accessibilityActivationPoint and accessibilityActivate.
Any help would be appreciated, thanks in advance.
Yes, you have the right idea with accessibilityActivate and accessibilityActivationPoint. Note that, in order for it to work, the accessibilityActivationPoint needs to be a point within the Control that you are trying to activate in on-screen coordinates (use the convert function!).
I think the short answer is "yes" to answer your second question, but, just to clear up confusion about when Accessibility Activation Point is useful, I'll go into more detail about it.
By default (aka, the default behavior for AcessibilityActivate()), when any view is activated by VoiceOver, VoiceOver will send a "tap gesture" to the center of the view. The position of this "tap gesture" can be changed by updating the accessibilityActivationPoint attribute on a view. Below, I have an example for how this property can be used.
Let's say you have a blank button (in the image below, the button is the gray box) next to some text:
For the purpose of accessibility, you may want to make the entire view that holds the button and text an Accessibility Element (so that VoiceOver users can easily understand that the button is associated with the text "Worldspace Attest"). In the image below, I am using Accessibility Inspector to show that the view holding both of these elements is an Accessibility Element.
Notice in these images that the button is not in the center of the view, but rather, it is to the right. When you activate this view using VoiceOver, the view will not select the button; instead, it will send a "tap" to the center of the view (which is the same as tapping the text, which does not do anything). In order to select the button, you have to set the view's accessibilityActivationPoint to be the on-screen coordinates of the button:
view.accessibilityActivationPoint = self.convert(button.center, to: UIApplication.shared.windows.first)
This should make it so that this button is usable by a VoiceOver user.
I hope this information clears up any confusion about the Accessibility Activation Point property. The example I used above can be found in this repository in the "Active Control Name" demo.

TToolbar Button with dropdown menu greyed out

I'm having issues getting a TToolbar Button to appear "enable"
The button has an Action assigned to it - which is fire by the OnClick event
It is also setup with a Drop Down Menu, which has 2 options on it, both of which are enabled, and both of which fire off when clicked.
Despite all this the TToolbar Button steadfastly remains greyed out, but accepts the clicks.
Any suggestions?
You're doing things wrong. :-)
When using actions, you don't use the button's OnClick event - you put the code in the action's OnExecute event instead (because that's what's executing - the action - and not the button). When an action is assigned to the control, the control cannot be enabled until there's a handler for the TAction.OnExecute.
The reason for using actions is so you can put the code in a single place (events related to the action), and then every single control attached to that action uses that common code to perform the same functionality. Editing the code in that single location means all controls attached to that action see the same changes.
If there's nothing attached to the TAction.OnExecute event, the control has nothing to do if it was selected (clicked), and so there's no reason to enable it in the first place.
In case someone else comes across this, I just had this problem (using Delphi 10.2 Tokyo).
For some reason, the "EnableDropdown" property on the TToolButton caused the button to to be greyed out when set to true. Setting this property to false seems to have resolved the problem for me (the dropdown menu remains functional anyway).

Detect second click on a segment

According to the documentation, the event which should related to UISegmentedControl is value changed. Assuming I have a segmented control with previous and next, in my case I should be able to click next more than one time, the default behaviour of UISegmentedControl will not recognize the successif second click on same segment. SO how to deal with that?
Set the momentary property of your UISegmentedControl to TRUE.
You can do that in code or in Interface Builder (there is a checkbox in the Attributes Inspector).

Ribbon buttons act like a group

I created 3 actions and assigned them to 3 buttons in a ribbon group. I want the buttons act like a group, one is always down, the others - up. Just like left/center/right align buttons.
I have set groupIndex property of my actions to 1. Help says:
"GroupIndex is used to define groups of actions that act like radio buttons. When GroupIndex is greater than 0, it identifies the group to which the action belongs. When the Checked property of any action in that group is set to true, the Checked property of all other actions in the group is set to false. That is, only one action in the group can be checked at a time."
But it is not working at all.
Any help?
Try to set the property AutoCheck = true for both items. It helped me =)
Without more information the only thing I can suggest is (if you are using tdxRibbon) is to check and make sure the buttonstyle property is set to bsChecked. Although it shouldn't let you set the group index otherwise.

Resources