Wrapper component for material toggle group (Angular 7) - angular-material

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

Related

Is there a specific component that works with Swift 3 to represent a "ComboBox / Spinner"?

I'm starting to work with Swift 3 and I'm having difficult to find a "easy" solution to create a "ComboBox/Spinner".
I saw some alternatives like using PickerView and Collapse TableView, but It seems to be a solutions to make these components to looks like a ComboBox, It's a adaptation, but It's not a "real comboBox".
I would like to know If there's a component that works with Swift 3 that really represents a ComboBox/Spinner.
Thank you.
As Eric says in his comment, controls aren't defined in Swift, they're defined in the OS frameworks.
iOS does not have a combo box. That's a Windows thing. The standard system component for picking items from a list is a UIPickerView. I've implemented a custom control that's rather like a combox box before, and you may be able to find a 3rd party control that does what you want.
Don't know if this is the kind of combobox system you are looking for:
https://gyazo.com/ce6388cf29f9c33f67df2b6a54c95768
If so you could create a custom button which looks like a combobox. Then if not selected you have an image of a not selected combobox and when someone selects the button change it to the image of a selected combobox.
You create an array, add the amount of custom buttons to the array as you want, you give each button the same selector. Then when someone selects an item, deselect another button if there is one selected and select the button the user did press.
I hope this helps you.

jQueryUI datepicker redisplays after selection

The datepicker is managed by knockout-jqueryui in a Durandal view presented as a modal dialog. The calendar pops up when the corresponding INPUT is focussed, and hides when it is blurred. Data-binding works fine.
But when the user selects a value, the calendar closes, the INPUT updates and the calendar re-displays. It works, but it's annoying my users because they are mouse obsessed and the calendar obscures the control below, making it hard to click on it. Yes, I know they could press tab. I have pointed this out.
How can I stop the re-display? Ideally, triggers for display would be focus and keydown. I have no problem with configuring it to manual control and switching with data-bind="change: showCalendar, ..." or similar, if that's how one does this.
So, what's the usual way to go about this? If it's manual control as I describe above, what are some keywords to expedite finding the relevant section(s) in the documentation? (How to set it to manual and how to hide/show it manually.)
(I found show() and hide())
The showOn option for jQuery UI Datepicker is passed through by knockout-jqueryui.
It defines only two values, 'focus' and 'button'.
There is no explicitly defined mechanism to disable auto-display, but I found that a value other than the defined values has the desired effect. I am passing 'click'.
Manual control methods are show and hide.

hide UI components at RUN TIME , design issue

on a form I need a first set of UI controls at process start, later I only need a second set of components. I put the set for process set #1 on a first panel , after finish process step #1 I start to hide panel #1, is ther any better way from UI design guide lines ?
I would use Frames instead of Panels. You can design Frames at design-time just like Forms, and then create instances of your Frames at run-time as needed. So create your first Frame (you can even place it on the Form at design-time) and then at run-time, when ready you can destroy the first Frame instance and create an instance of the second Frame.
Using panels like you describe is a very common and very respectable way to proceed. Nothing wrong with doing it that way.
Another often used idiom is a page control with hidden tabs. So, make a page control. Add two tab sheets. Set TabVisible to False for both tab sheets. Then at run time set the ActivePage property of the page control to specify which page is shown to the user.
The page control approach is really rather similar to using panels. It's perhaps marginally easier to work with at design time, but much comes down to personal preference.

BlackBerry - arrange checkboxes into a tree view

I am trying to achieve something like this BlackBerry 7.1:
But so far I couldnt find or come up with a way to achieve something like this. All I could find was "BlackBerry - TreeField with Checkboxes?" but this really is not what I want since selecting the parent checkbox does not select all of the child checkboxes and whenever I want to select a checkbox I have to deal with an extra menu. Is there any other way to achieve this ?
The indentation is feasible, and the logic, you'll have to craft it on your own.
You could set a FieldChangeListener on every checkbox field so that you can detect when a checkbox have been checked/unchecked. If the parent is checked or unchecked, manually call setChecked over each children field to check/uncheck them. For the children, when one is unchecked, uncheck the parent.
This is the basic logic for a single nesting level (parent and children) Make sure to check in the listeners that the event firing the update of the binded checkbox fields is user generated (not programmatic), because the change listener is also called back when you programmatically call setChecked. If not taken into consideration, you'll run into undesired propagation and infinite loops. Of course, if you had more than one level of nesting, then you'll need to care about programmatically fired events.

In TButtonGroup.ButtonOptions what does adding gboGroupStyle do?

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.

Resources