C++ GtkWidget set default radio button in a group - radio-button

using GtkWidgets I have created radio buttons as follows:
GtkWidget *radio1, *radio2;
radio1 = gtk_radio_button_new (NULL);
radio2 = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON ( radio2 ));
When I launch the window radio1 is selected by default. Is there any way to change the default selection to radio2?

This should do it:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio2), TRUE);

Related

Kotlin how set a button listener to use another button inside it

There is a bookbutton and are around 10 buttons in my program each one contains a specific value.
How to make bookbutton save the data depending on what the user choose from the 10 buttons
This is simple code of what I've tried to do to link a button with the bookbutton.
var i = 10
button1.setOnClickListener {
bookbutton.setOnClickListener {
i++
textview.text = "$i"
}
}
You're setting the listener on button2 within the button1 click, not enabling it.
Try to do button2.isEnabled = true inside the button1 click listener, and set the button2 click listener outside of it:
var i = 10
button2.isEnabled = false // disable by default (you can do this in XML instead)
button1.setOnClickListener {
button2.isEnabled = true
}
button2.setOnClickListener {
i++
textview.text = "$i"
}

How to activate the window that comes with idea through code?

I want to develop a plugin that prints in the console window, but I don't want to customize the Tool Window component。
This is how I currently do it:
ToolWindow toolWindow = ToolWindowManager.getInstance(e.getProject()).getToolWindow("Run");
toolWindow.show();
ContentManager contentManager = toolWindow.getContentManager();
ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(e.getProject()).getConsole();
Content content = contentManager.getFactory().createContent(consoleView.getComponent(), "Generator", false);
contentManager.addContent(content );
contentManager.setSelectedContent(content);
consoleView.print(text, ConsoleViewContentType.NORMAL_OUTPUT);
consoleView.scrollTo(consoleView.getContentSize()-1);
But I found that if the window is not activated, the getToolWindow method gets null。
Is it possible to activate the window directly by means of code, rather than by activate it from the View -> Tool Windows menu?

Checking values in a parent object

Recently, I have been working on a game project and decided to learn how to make a gui from scratch in love2d while I was at it. I decided to use OOP where I had menu objects and button objects within the menu objects. I had a problem where I only wanted to draw the buttons only if the menu was active. The easiest/best way to do this is probably to have a function in the menu object that checks if the menu is active and draw the buttons if it is like this...
menu = {
-- menu stuff
button = require("path")
active = false,
buttons = {}
}
function menu.newButton()
--create new button object from button table
end
function menu:drawButton()
if self.active then
for k,v in pairs(buttons)
menu.buttons[k]:draw() -- some draw function that sets the size, pos, and color of the button
end
end
end
This got me wondering though. Is there some way to check values in the menu's table from a function located in the button's table?
You can use composition to access properties of Menu object from a Button. To do that you would need to pass a reference to the menu object when constructing every new Button. For instance:
Button = {}
function Button.new (menu)
return setmetatable({menu = menu}, {__index = Button})
end
function Button:getMenuName()
return self.menu.name
end
menu = {
name = "menu1",
buttons = {},
}
function menu:newButton ()
local button = Button.new(self)
table.insert(self.buttons, button)
return button
end
local btn = menu:newButton()
print(btn:getMenuName())
Would print the property name of menu from object btn.

Adding a Back button to a iOS app in Titanium Appcelerator without TabGroup or NavBar

I'm developing with Titanium Appcelerator for iOS. I would like to manage manually a 'back' button using the properties of window, that can set a left and right buttons.
I'm trying with this code:
var win = Titanium.UI.currentWindow;
win.backgroundColor = '#FFF';
var b = Titanium.UI.createButton({title:'Back'});
win.setLeftNavButton(b);
b.addEventListener('click', function()
{
win.close();
});
But no button is showed.
Swanand is right but i want to add some more thing that if you use modal property of window to open then also you can use setLeftNavButton method to set button in navigation bar but if you do not want to use tab group or navigation group or even modal property then you need to add that button in window with left,top,width and height property.
You can use below example....
var win = Titanium.UI.currentWindow;
win.backgroundColor = '#FFF';
var b = Titanium.UI.createButton({
title:'Back',
width : Ti.UI.SIZE,
height : Ti.UI.SIZE,
top : 10,
left : 10
});
win.add(b);

Selecting radio button in geb

I have 3 radio button in a form with ID, value, and name.
With Geb CSS selector I have tired all combination to click on of the radio button but no success!!
I have tried testBtn {$("input", ID:"resident", name:"status")} then in spec testBtn.value("My status") where radio button value="My status", but label next radio button is "Status". Any help appreciate.
You probably don't want to use the id in your selector as this would select only one radio. To mark a radio button as selected you set a value on a set of radio buttons with a given name. For your example that would be:
$('input', name: 'status').value('My status')
or if you used content DSL:
static content = {
status { $('input', name: 'status') }
}
status = 'My status'
Please refer to the section on selecting radio buttons in the Book of Geb.