Manu Gupta write:
> Hi All
> 
> I have been trying to use RadioButton and RadioButtonGroup using
> libyui but I am unable to do so Can anyone have a look at my code and
> tell me how do I do it?
> 

Hi,
at first thanks for feedback. At second I want to note that I am not author of 
libyui and I just fix your code by looking in documentation and source code.

Mistake you do is that addRadioButton should be called only in constructor by 
documentation, but when I look in code it doesn't use at all. Actually 
RadioButton detect its group just by searching its parents and match first 
radioButtonGroup ( Yes, I also think that it is not perfect solution ).

So I attached modified your code which actually works.

Conclusion:
RadioButton use first RadioButtonGroup which it find as its parent.

Josef



-- 
Josef Reidinger
Appliance Toolkit team
maintainer of perl-Bootloader and parts of webyast and SLMS
author of rubygems - studio_api and net_observer (coauthor)
#include<iostream>
//#include<stdlib.h>
#define YUILogComponent "quizgame"
#include "YUILog.h"
#include "YUI.h"
#include "YWidgetFactory.h"
#include "YDialog.h"
#include "YLayoutBox.h"
#include "YRadioButtonGroup.h"
#include "YRadioButton.h"
#include "YLabel.h"
#include "YPushButton.h"
#include "YEvent.h"
#include "YAlignment.h"
#include "YMenuItem.h"
#include "YMenuButton.h"

//#include  "base.h"

YItemCollection fillMenu(){
	YItemCollection items;
	items.push_back( new YMenuItem("&Close"));
	return items;
}

int main(){
//	item("Manu","Gagan","Tiger","Lion","Duck",4).getAnswer(4);

	YUILog::setLogFileName("/tmp/quiz/quiz.log");
	YUILog::enableDebugLogging();


	YDialog * dialog = YUI::widgetFactory()->createPopupDialog();
	YAlignment * minSize = YUI::widgetFactory()->createMinSize(dialog,100,4);
	YLayoutBox * mbox = YUI::widgetFactory()->createVBox(minSize);

	YAlignment * margin = YUI::widgetFactory()->createMarginBox(mbox,1,1);

	
	YLayoutBox * vbox = YUI::widgetFactory()->createVBox(margin);
	
	YMenuButton * mFile = YUI::widgetFactory()->createMenuButton(YUI::widgetFactory()->createLeft(vbox),"&File");
//MenuItem * item = new YMenuItem("&Close");
	mFile->addItems(fillMenu());

	YLabel * question = YUI::widgetFactory()->createLabel(YUI::widgetFactory()->createLeft(vbox),"Manu akjsdhkashd adsk askdjksahd ksa dkhdsakjdsa dsa");


	YRadioButtonGroup * ansGroup = YUI::widgetFactory()->createRadioButtonGroup(YUI::widgetFactory()->createLeft(vbox));
	YLayoutBox * vbox2 = YUI::widgetFactory()->createVBox(ansGroup);
	YRadioButton * ans1 = YUI::widgetFactory()->createRadioButton(YUI::widgetFactory()->createLeft(vbox2),"ANS 1dasda da dsa daslk sad lsakjd ldks ");
	YRadioButton * ans2 = YUI::widgetFactory()->createRadioButton(YUI::widgetFactory()->createLeft(vbox2),"ANS 2dasda da dsa daslk sad lsakjd ldks ");
	YRadioButton * ans3 = YUI::widgetFactory()->createRadioButton(YUI::widgetFactory()->createLeft(vbox2),"ANS 3dasda da dsa daslk sad lsakjd ldks ");
	YRadioButton * ans4 = YUI::widgetFactory()->createRadioButton(YUI::widgetFactory()->createLeft(vbox2),"ANS 4dasda da dsa daslk sad lsakjd ldks ");

	YPushButton * nextButton = YUI::widgetFactory()->createPushButton(YUI::widgetFactory()->createRight(vbox),"&Next");
	YEvent * event = dialog->waitForEvent();

	return 0;
}

Reply via email to