Selecting a polygon makes text appear on top of a second polygon. BUT! Another unique text does NOT appear on the 3rd polygon

Hello All!
I have 2 polygon-text interactions issue that are different from the ones in the forums so far. Since they may be inter-related, I’ve included both errors below.

OS Win 10
PsychoPy version (2024.1.2):
Standard Standalone? (y/n) yes

What are you trying to achieve?:

I have 3 polygons as 3 possible buttons that the participant can click on: rectangle1, rectangle2, and rectangle3

When a participant clicks on one of the rectangles,
the rectangle turns yellow and these polygons and texts appears:
a “submit” polygon button,
a “submit” text on top of the submit polygon button,
a “cancel” polygon button,
and a “cancel” text on top of the cancel polygon button should appear.

ERROR 1: currently, all except the “cancel” text appears.

Additionally, when the participant clicks on the cancel button,
the Submit polygon, submit text, cancel polygon, and cancel text should all disappear. In addition, the rectangle turns back to its original color (black)

ERROR 2: All except the “submit” text disappears.

What did you try to make it work?:

Under “Begin Routine”

cancel_button.opacity = 0
confirm_button.opacity = 0
button_is_pressed = False

Under “Each Frame”

#if cancel_button.contains(mouse_handler):
#    cancel_button.fillColor = 'yellow'
#    cancel_button_text.pos = (.35, -.85)
#    cancel_button_text.color = 'black'
    
#else:
#    cancel_button_text.pos = (.35, -.85)
#    cancel_button_text.color = 'black'

if mouse_handler.isPressedIn(rectangle1):
   button_is_pressed = True
else:
   button_is_pressed = False

   if button_is_pressed == True:

        #make next button opaque
        confirm_button.opacity = 1
        confirm_button_text.opacity = 1
        confirm_button_text.setText('Submit')
        
        #CANCEL BUTTON (and text) APPEARS!
        cancel_button.opacity = 1
        cancel_button_text.opacity = 1
        cancel_button_text.setText('Cancel')

##   #ERROR: does not seem to register ##########################################
        #cancel_button_text.opacity = 1
        #cancel_button_text.setOpacity = 1
        #cancel_button_text.updateOpacity(1)

        #if click on cancel button, the text "Submit" should disappear
        if mouse_handler.isPressedIn(cancel_button):
            confirm_button_text.setText('Submit')
            confirm_button_text.opacity = 0
            confirm_button_text.opacity = 0
            
        #if submit button clicked, display answer info and next button
        if mouse_handler.isPressedIn(confirm_button):
            
            #cancel button disappears
            cancel_button.opacity = 0
            #cancel_button_text.setOpacity = 0
            #cancel_button_text.opacity = 0

        if cancel_button.opacity == 1 and 
             mouse_handler.isPressedIn(cancel_button):

            #make sure the next button says submit again when it reappears
            confirm_button_text.setText('Submit')
            
            #confirm button not visible
            confirm_button.opacity = 0
            confirm_button_text.opacity = 0
            
            #submit button not visible either ... 
            confirm_choice_button_text.opacity = 0
            confirm_choice_button.opacity = 0
            
            #once clicked on, cancel button no longer visible
            cancel_button.opacity = 0
            cancel_button_text.opacity = 0
        
            #no selection
            button_is_pressed = False

What specifically went wrong when you tried that?:
Note that I did not receive any syntax errors nor other errors than those 2 listed above.

Additional changes I tried and commented out yielded no difference in appearance.

Tried setting the text to “Cancel” when I tried to make the cancel button opacity = 1 and set the text setOpacity = 1. (saw a post that recommended that)

Picture1

Can you submit an image of your builder view?


If you want the opacity to be 0 in Begin Routine, I would set in in the component itself (0 each repeat). What do you currently have as the opacity in the routine?

Personally, I often use position rather than opacity in this case, with a starting position of [2,2] (off screen)

When the opacity is set to 0 within the component, it never appears.
When the opacity is set to 1 within the component, it always appears.

The text opacity will not change at all when placed behind or on top of the polygon component, even when told to change its opacity in the code component. When placed OUTSIDE of the polygon, it seems possible to turn on the opacity of the text (text set to text.opacity = 0 and =1 in an if/else statement).

SOLUTION: Set opacity = 1 within the component and have it drawn at a position off of the screen. Within the code component, instead of trying to change the text opacity, have it change it’s position on/off the screen based on wanted logic.