OnClick event triggered by other inputs.
I have something like this:
cols = st.columns([2,1])
draw = ImageDraw.Draw(image2)
draw.ellipse((20, 20, 180, 180), fill = None, outline ='blue')
with cols[0]:
value = streamlit_image_coordinates(image2)
if value:
st.session_state['points'].append(value)
cols[1].number_input("False positive",format="%i",step=1,key=f"img_proc_pos_{i:d}")
cols[1].number_input("Misses",format="%i",step=1,key=f"img_proc_neg_{i:d}")
cols[1].button("Clean points", on_click=clean_points)
If I click on any of the inputs or button above, I will trigger an onclick event on the image and streamlit_image_coordinates will return a value of the last clicked point on the image.
Just to clarify: clicking on other components, like inputs and buttons, should lead to last "value", but to a None "value".
Yes, I observe that when other components (e.g. inputs,...) are clicked on, the streamlit_image_coordinates returns the previously clicked coordinates... So, if I am recording the coordinates into a session (e.g. with a condition "if value:"), every click of another component leads to a false coordinate record... So far I could solve this by saving the last coordinate into a session and than comparing if the new "image click" value is the same, or not.
I have to do sth like this in order to prevent false clicks:
image = draw_points(image,key,color)
value = streamlit_image_coordinates(image,key="local")
if value and value!=st.session_state['last_point']:
st.session_state['last_point'] = value
st.session_state[key].append(value)
st.rerun()