Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Mouse Button Down Event?

edited March 2015 in OpenSesame

Does anyone have any experience of recording whether a mouse button is being held down? As in not just a click, but holding the button down like you would when dragging a window. I have experimented with the mouse.getpressed function but this doesn't seem to distinguish between click then release, and click then hold.

Alternatively, is there a way to record (on the android version) whether an area of the screen is being touched? I would like to make an event that only occurs when a participant lifts their finger off the screen.

Thanks!

Comments

  • edited 11:56PM

    Hi George,

    Me myself, I don't have much experience with mouse button down events or the android version. However, I'm quite sure that what you describe should be doable with OpenSesame. Maybe, you could have a look on this discussion? It seems to have a similar topic that your question has.

    Good luck and let us know if you need more help.

    Eduard

    Buy Me A Coffee

  • edited March 2015

    Hi George,

    The openexp.mouse.mouse.get_pressed does give information on which buttons are down!

    It returns a Boolean vector, basically a tuple with a 1/0 (down/up) value for all buttons. If you want participants to be able to drag something, you could very easily use the get_pressed output. Example:

    from openexp.canvas import canvas
    from openexp.mouse import mouse
    
    # create objects
    my_canvas = canvas(exp)
    my_mouse = mouse(exp)
    
    # stimulus specifics
    cpos = (100, 100)
    stimradius = 15
    
    while True:
        # get mouse position
        mpos, timestamp = my_mouse.get_pos()
        # get mouse button state
        # (e.g. (1,0,0) for a left button press)
        pressed = my_mouse.get_pressed()
        # if the left button is pressed, and the mouse is on the
        # moveable stimulus, update the position
        if pressed[0] == 1 and ((mpos[0]-cpos[0])**2 + (mpos[1]-cpos[1])**2)**0.5 < stimradius:
            cpos = mpos[:]
        # break if the right button is pressed
        elif pressed[2] == 1:
            break
        # clear the canvas
        my_canvas.clear()
        # draw stimulus
        my_canvas.circle(cpos[0], cpos[1], stimradius, color="#ff69b4", fill=True)
        # draw the mouse cursor
        my_canvas.fixdot(x=mpos[0], y=mpos[1], style="small-cross")
        # show canvas
        my_canvas.show()
    

    On your second question, of specifically picking up button releases: you could monitor the get_pressed output and check for transitions of 1 to 0. Alternatively, you could use PyGame directly (this is the underlying library for both the legacy and droid back-ends). To do this, you will need to monitor pygame.event.get() for a pygame.MOUSEBUTTONUP event (for more info, see the PyGame documentation).

    Good luck!

  • edited 11:56PM

    Thanks eduard and Edwin, that is really helpful. I have the task working now. My mistake on the mouse.get_pressed function!

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games