I want to change the checked state of multiple buttons with MaterialButtonToggleGroup - slider

There are five buttons, and the text of the button is a number from 1 to 5.
I implemented it using the check() function. For example, if you press the button where 3 is stored in the text, the buttons 1 and 2 are automatically checked.
binding.sweetnessRadioGroup.addOnButtonCheckedListener { group, checkedId, isChecked ->
val a = group.findViewById<Button>(checkedId).text.toString().toInt()
if (isChecked) {
for (i in 1..a) {
group.check(group.get(i-1).id)
} else {
for (i in 5 downTo a) {
group.uncheck(group.get(i-1).id)
Up to this point, it works normally, but when a high value is checked and a low value is checked, I want to uncheck the value in between
For example, if buttons 1 to 5 are checked and button 3 is pressed, 4 and 5 should be unchecked.
I tried the uncheck() function, but strangely, the check state of the rest of the buttons is not unchecked.
However, when button 3 is pressed again, button 3 is checked and the checked status of buttons 4 and 5 becomes unchecked.
please help

Related

PowerBuilder Changing button text depending on database column value

In my database I have a column where default_column_value = 1.
I currently have a button that displays the text "Pay Enabled". When clicked, this button toggles the column value between 1 and 0. When the column value is at 1 the button should display "Pay Enabled" When it is at 0 it should display "Pay Disabled". What is the best way to achieve this?
Below is the window where I have programmatically added the button.
btn_add("Pay Enabled", true)
btn_add()
ii_blank_btns += 1
blank_btns[ii_blank_btns].object.t_text.y = 50
blank_btns[ii_blank_btns].object.t_text.text = as_name
blank_btns[ii_blank_btns].object.c_color.expression = '0'
blank_btns[ii_blank_btns].GroupCalc()
blank_btns[ii_blank_btns].visible = true
Properties Image
Use a datawindow button, that is a button defined in the datawindow.
In the properties of that button, click on the 'Expression' icon of the text and put something like if(col_value = 1, 'Payment Enabled', 'Payment Disabled').
See hereunder the 'Expression' button is on the right of the text 'none' and contains the expression above.

Getting Button state in XCUITest

How to get button state in XCUITest?
It is just a NSButton which acts as a toggle button. The images changes upon clicking. In application i check with button.state which returns 0 or 1. depending upon the values i changes the images.
#IBAction func checkBoxClick(sender: NSButton) {
print("Checkbox state ", sender.state)
}
But when writing XCUITest automaton code, i am not able to get the state of the button. there is no attribute like state. Also when i take 'value' or 'selected' attributes of the button it always gives nil and false.
let window = XCUIApplication().windows["Window"]
let button = window.buttons["Button"]
button.click()
print("Button selected ",button.selected)
print("Button selected value ",button.value)
button.click()
print("Button unselected ",button.selected)
print("Button unselected value ",button.value)
Values printed are
Button selected false
Button selected value nil
Button unselected false
Button unselected value nil
Any inputs.
In your application code, you could map the 0/1 state to selected/not selected. Default state should be false and when it is toggled, invert the state of sender.selected.
The selected property represents two states and provides the same functionality as your .state addition.

how can i give multiple actions to button on iPhone

I have two buttons,if the first button is clicked two textfields will come and the second button dimension will change to next to the textfields.Now if i click the second button one textfield will appear.I did all those things.Now my question is if we click the second button,textfield will appear with what ever the dimensions we have given,but if we click the second button after clicking the first button also dimensions should change.Can any one help to do this.
Thank You
you can add multiple selectors on a single button for different control states
Your question is vaguely phrased. If I understood correctly, when the second button is pressed, you want two different actions done depending on whether the first button has previously been pressed or not. If that's the case, the solution is to define a boolean flag, which will be set to YES when the first button is pressed, and will be set to NO (if needed) after the second button's action is completed.
In your header file:
#interface yourViewController: UIViewController {
BOOL firstButtonFlag;
}
And in yourViewController.m file:
-(void)viewDidLoad {
firstButtonFlag = NO; // technically redundant line, just to show the concept
}
-(IBAction)firstButtonPressed {
firstButtonFlag = YES;
// whatever action you want done
}
-(IBAction)secondButtonPressed {
if (firstButtonFlag) {
// whatever action if first button had been pressed before
firstButtonFlag = NO; // resetting the flag for next round
}
else {
// whatever action if first button had NOT been pressed before
}
}

NSMenu with 2 standard + variable number of NSMenuItems

I have an NSMenu with 2 default items (at the top of it).
Then the rest of the menu will be populated.
What I want is to "save" the state of the initial menu (with the two items in it), and add items to that (original) menu; and not just keep adding and adding.
So, if I have to add other items, those will have to be added in the initial menu.
Example :
Menu At the beginning : A B |
Menu After User does This : A B | C D E
Menu After User does That : A B | G H I J K
etc
How should I go about that? (I tried "saving" the initial menu, and then "copying" that to the current menu, so that I could add items on top of it, but it didn't work... :-S)
[DOC_UI setCurrentMenu:[[DOC_UI originalMenu] copy]];
// I'm adding the items here
for (NSMenuItem* mi in [[DOC_UI currentMenu] itemArray])
NSLog(#"orig :: mi : %#",[mi title]);
/* The weird thing is that the items ARE NSlogged, but the change is NOT reflected. */
/* (When I was just adding to the existing items, the items did show up...) */
If you're talking about menu items of a menu, you can remove all but the first 2 items in a loop when you want to go back to your original menu. If you have a menu with 2 default items called userMenu, just do this:
-(void)removeMenuItems {
for (NSInteger i=self.userMenu.itemArray.count - 1; i>1; i--) {
[self.userMenu removeItemAtIndex:i];
}
}

Modify cell content when row created in Rad grid

I have a rad grid dynamically created. I have a status column in database. When binding the value to the grid, I want to show a de-activate button when status is 0 and activate button when status is 1. Upon clicking the button, the status should change from active to inactive and vice versa? What should be the column type and how to write an event for the button click?
I have accomplished the same task as shown below :
GridButtonColumn btncol = new GridButtonColumn();
btncol.ButtonType = GridButtonColumnType.LinkButton; // setting ButtonType as LinkButton
btncol.DataTextField = "Active"; // setting DataTextField to first column in DataTable
this.RadGrid1.MasterTableView.Columns.Add(btncol);
Better example is given in following link :
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html