0 votes
by (320 points)

I am conducting a psychophysics experiment and I need subjects to respond by clicking on yes or no buttons. How can this be done?


Thank you for the reply.

1 Answer

+2 votes
by (14.5k points)
selected by
Best answer

Samy hi,

GUI Panel element can be easily used for that. The element creates and handles a custom GUI widget on the screen, with a content defined by a XAML script. However, there are some limitations. For example, you can not use the XAML Button class, because it would require a non-XAML code to handle button clicks, which is not supported in EventIDE.

However, there is a simple workaround. Use the  XAML ToggleButton class instead of Button. The ToggleButton  can be bound to a global bool variable that would indicate one of 2 button states: pressed or unpressed. Here, for example, an implementation of  the 'Yes-No' response panel: 

Header snippet:

bool IsYesResponse=false;
bool IsNoResponse=false;

XAML script for the GUI panel element:

<StackPanel Orientation="Horizontal">
	<ToggleButton Content="Yes" IsChecked="{Binding IsYesResponse}" Width="50" Margin="10"/>
	<ToggleButton Content="No" IsChecked="{Binding IsNoResponse}"  Width="50"  Margin="10"/>	

Resulting GUI widget:

Now, each time a participant clicks on either button, the corresponding bool variable turns 'true'. it would work for the scenario when you need to detect a single button click, but don't forget to reset the bound bool variables to 'false' before showing the widget again. 

Sometimes, you may need to detect multiple clicks on the same button and run some actions in response. It can be done with the Toggle Buttons too, using a code trick. Add the following code in the 'Control Loop' of the parent event:

if (IsYesResponse==true) /// the YES button is pressed
    RT1=EventElapsedTime; // record the press time
    /// do other actions
    IsYesResponse=false;// reset the button to the unpressed state by its bound variable
if (IsNoResponse==true) /// the NO button is pressed
   RT2=EventElapsedTime; // record the press time
   /// do other actions
   IsNoResponse=false;// reset the button to the unpressed state by its bound variable

Since this code is in the 'Control Loop' snippet, it checks the button states continuously and catches all button presses. The Toggle Button behaves as a normal button for participants because it is instantly restored into the unpressed state after a made click. 

Welcome to EventIDE Q&A forum where you can ask questions about EventIDE software and receive answers from other members of the community


FAQ questions

Installation and License



EEG Analysis

Visual Stimuli

Runtime and Data Collection