expyriment.io.TouchScreenButtonBox

class expyriment.io.TouchScreenButtonBox(button_fields, stimuli=[], background_stimulus=None)

A class implementing a TouchScreenButtonBox.

__init__(button_fields, stimuli=[], background_stimulus=None)

Initialize a touchscreen button box.

Parameters:
button_fieldsvisual Expyriment stimulus or list of stimuli

The button fields defines the area on which a click action will be registered.

stimulivisual Expyriment stimulus or list of stimuli, optional

Additional visual stimuli that will be presented together with the button fields. Stimuli are plotted on top of the button_fields.

background_stimulusvisual Expyriment stimulus, optional

The background stimulus on which the touschscreen button fields are presented. Importantly, background_stimulus has to have size of the screen.

Notes

Every visual Expyriment stimulus can serve as a touchscreen button field. If the TouchScreenButtonBox is presented, it can be checked for events using the methods ‘check’ and ‘wait’.

add_button_field(button_field)

Add a touchscreen button fields.

Parameters:
button_fieldvisual Expyriment stimulus
add_stimulus(stimulus)

Add additional stimulus

The added stimulus will be presented together with the button fields.

Parameters:
stimulusvisual Expyriment stimulus
property background_stimulus

Getter of background stimulus.

Background stimulus, on which the button fields and the additional stimuli will be presented. (visual Expyriment stimuli)

property button_field

getter of button fields (list of visual Expyriment stimuli)

check(button_fields=None)

Check if a button field is clicked.

Parameters:
button_fieldsExpyriment stimulus or list of stimuli, optional

The button fields that will be checked for.

Returns:
pressed_button_fieldExpyriment stimulus or list of stimuli, optional

The button fields that will be checked for.

touch_timeinteger

The time when the button was touched. Function might return delayed, because button field comparison (after touch) takes time. The return time is most accurate.

Notes

Don’t forget to show the TouchScreenButtonBox.

clear_event_buffer()

Clear the event buffer of the touchscreen/mouse input device.

create()

Create the touchscreen buttonbox.

Prepares the button fields and additional stimuli for fast presentation.

property last_touch_position

getter for the last touch position (x,y)

property logging

Getter for logging.

set_logging(onoff)

Set logging of this object on or off

Parameters:
onoffbool

set logging on (True) or off (False)

show()

Present touchscreen buttons.

property stimuli

getter of additional stimuli (list of visual Expyriment stimuli)

wait(duration=None, button_fields=None, callback_function=None, process_control_events=True)

Wait for a touchscreen button box click.

Parameters:
button_fieldsExpyriment stimulus or list of stimuli, optional

The button fields that will be checked for.

durationint, optional

maximal time to wait in ms

callback_functionfunction, optional

function to repeatedly execute during waiting loop

process_control_eventsbool, optional

process io.Keyboard.process_control_keys() and io.Mouse.process_quit_event() (default = True)

Returns:
pressed_button_fieldExpyriment stimulus or None

the button field defined by a stimulus that has been pressed

rtint

reaction time

Notes

This will also by default process control events (quit and pause). Thus, keyboard events will be cleared from the cue and cannot be received by a Keyboard().check() anymore!

Don’t forget to show the TouchScreenButtonBox.