How to reset Option Buttons in Group Box control in Impress?

Creating a macro - Writing a Script - Using the API

How to reset Option Buttons in Group Box control in Impress?

Postby Lucnes » Tue Oct 21, 2008 10:17 am

Hello everyone!
I am new of 3.0 and unfortunately I don’t know the Basic language :(
I have found on Internet an article that illustrates like creating interactive forms with Writer that consists of a series of multiple choice questions. Here it is in detail:
I have created a Group Box containing Option Buttons with the defined answers. Then in order to make the form interactive, I have added some simple macro associated with Option Button to inform me whether the selected answer is correct or no. I have also created a Reset button that clears all the answers by means of its macro (ResetControls). Here it is the code:

Sub CorrectAnswer
Message="The answer is correct!"
MsgBox Message
End Sub

Sub IncorrectAnswer
Message="The answer is incorrect!"
MsgBox Message
End Sub

Sub ResetControls
oDoc = thisComponent
oDrawPage = oDoc.getDrawPage()
oForms = oDrawPage.getForms()
oForm = oForms.getByName("Standard")
End Sub

It works very well on Writer, but when I copy the code into Impress it does not completely work… only two macro work, that is CorrectAnswer and IncorrectAnswer, but no ResetControls… Why?
I am really trying to use this system in Impress by means of OpenCards extension in order to make it an interactive tool with the multiple choice questions by means of Option Buttons: only one of possible answers is correct and it is selectable through its Option Button.
I use slide-title as flashcard front on which I write the correct answer, and the slide-content as its back on which I write both question and five possible answers with their Option Button.
During last-minute learning session OpenCards shows both question and its answers in the slide-content, and on this event it would need a macro, said ResetControls, to reset any Option Button automatically without having to click some Reset-button (like in the Writer example), so that no answer is selected. I would not want to implement a Reset button.
At this point I select an answer and then click on the Complete Shows Card-button in the Choose Action window. During this event OpenCards shows correct answer written in the slide-title, but it changes current selected answer (in Option Button) with previous chosen answer. It would need another macro, said MaintainAnswer, in order to continue to show the current selected answer that it is confronted with correct answer written in the slide-title. If the answer is corrected then Perfectly-button is clicked, otherwise Not at all-button is clicked, and OpenCards shows next slide. The cycle is closed and it newly begins from head with ResetControls macro that it resets any answer-Option Button, and so on…

Can someone realize these macros and share them with all community?

P.S. I have attached an example file without macro:
Multiple choice questions.odp
(13.19 KiB) Downloaded 210 times

Thanks very much for your help!! :)
OOo 3.0.X on Ms Windows XP
Posts: 1
Joined: Tue Oct 21, 2008 9:36 am

Re: How to reset Option Buttons in Group Box control in Impress?

Postby Bhikkhu Pesala » Tue Oct 21, 2008 10:34 am

I removed the green tick from your post, otherwise people might think that you solved the problem yourself already.
Free Speech and Right Speech
OOo 3.0.X on Ms Windows XP
Bhikkhu Pesala
Posts: 1253
Joined: Mon Oct 08, 2007 1:27 am

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests