Ace Editor - How To Get Apply Button Action

Hello guys.
Is it possible to get the click action in the main button of the code editor ‘‘streamlit_ace’’.

import streamlit as st
from streamlit_ace import st_ace

content = st_ace(language='sql', keybinding="vscode", value='initial value')

I need to get the click action in the Apply button of this editor. How can I do that ?

According to example, just use content as if it is a boolean True.

if content:
    st.subheader('Content')
    st.write(content)

If content is True, that means the user pressed the apply button.

I tried using in that way. But as I’m setting a value for the content, when I load the page the content is already True.

I need to set a start value, because I’m doing something to edit an existing code.
So, I select a code and this code is loaded to the ace editor.

In that case, the initial content is displayed. But the moment you edit something and press the apply button, the if content also works.

If detection of pressing a button is critical in your application, we can use a session variable to detect the first time the app started or the first time the session started.

import streamlit as st
from streamlit_ace import st_ace

if 'cnt' not in st.session_state:
    st.session_state.cnt = 0

content = st_ace(language='sql', keybinding="vscode", value='initial value')

st.session_state.cnt += 1

if content:
    if st.session_state.cnt > 1:
        st.write('button is pressed')
    else:
        st.write('button is not pressed')

    st.subheader('Content')
    st.write(content)