Millisecond Forums

How to click a button to return event

https://forums.millisecond.com/Topic36406.aspx

By ben liu - 7/21/2024

I hope that when the continue button, start, and end buttons are pressed, the event can be returned through the following port, but it seems that the event is sent out when the screen show.
How to send event when pressing button ?
Thank you so muck.





--------------------------------------------------------------------------------------------------------------------
<trial instructions>
/ ontrialbegin = [
    if (trial.instructions.trialcount > 0){
        button.continuebutton.skip = true;
        button.start.skip = false;
    } else {
        button.continuebutton.skip = false;
        button.start.skip = true;        
    };
]

/ stimulustimes = [1=clearscreen, instructions , continuebutton , start , end, myPort]
/ inputdevice = mouse
/ validresponse = (continuebutton, start, end)

/ ontrialend = [
    if (trial.instructions.response == "continuebutton") {
        
        port.myPort.setitem(1);
    } else if (trial.instructions.response == "start") {
        
        port.myPort.setitem(2);
    } else if (trial.instructions.response == "end") {
        
        port.myPort.setitem(3);
    }
]
/ recorddata = false
</trial>


<port myPort>
/ port = COM3
/ subport = data
/ items = ("00000100","00000101","00000110") //4,5,6
</port>
By Dave - 7/22/2024

ben liu - 7/21/2024
I hope that when the continue button, start, and end buttons are pressed, the event can be returned through the following port, but it seems that the event is sent out when the screen show.
How to send event when pressing button ?
Thank you so muck.





--------------------------------------------------------------------------------------------------------------------
<trial instructions>
/ ontrialbegin = [
    if (trial.instructions.trialcount > 0){
        button.continuebutton.skip = true;
        button.start.skip = false;
    } else {
        button.continuebutton.skip = false;
        button.start.skip = true;        
    };
]

/ stimulustimes = [1=clearscreen, instructions , continuebutton , start , end, myPort]
/ inputdevice = mouse
/ validresponse = (continuebutton, start, end)

/ ontrialend = [
    if (trial.instructions.response == "continuebutton") {
        
        port.myPort.setitem(1);
    } else if (trial.instructions.response == "start") {
        
        port.myPort.setitem(2);
    } else if (trial.instructions.response == "end") {
        
        port.myPort.setitem(3);
    }
]
/ recorddata = false
</trial>


<port myPort>
/ port = COM3
/ subport = data
/ items = ("00000100","00000101","00000110") //4,5,6
</port>

<port> elements are stimulus elements like any other. You need to "display" them just like any other stimulus element. In this case, if you want a stimulus (here: a <port>) "displayed" upon a response, you need to make use of the <trial>'s /responsemessage.

You should take a look at the Auditory Oddball Task in the library, which illustrates proper use of <port> elements.

https://www.millisecond.com/download/library/oddball