fixed context menu long press open

This commit is contained in:
Andreas Fruhwirt 2025-04-05 19:29:54 +02:00
parent 3943a8bc7c
commit 3db9ce34f5
2 changed files with 18 additions and 11 deletions

View File

@ -74,6 +74,7 @@ def is_authorized(credentials: Annotated[HTTPBasicCredentials, Depends(security)
def refresh_ui_enabled(client_id):
global client_data
if client_id in client_data:
with client_data[client_id].container:
if client_data[client_id].websocket.generating:
enable_ui(client_id, 2)
@ -83,7 +84,6 @@ def refresh_ui_enabled(client_id):
stop_recording(client_id)
return
enable_ui(client_id, 0)
return
def after_websocket_init(client_id):
if hasattr(client_data[client_id], "websocket") and not client_data[client_id].websocket.stopped.is_set():
@ -224,7 +224,7 @@ async def main_page(credentials: Annotated[HTTPBasicCredentials, Depends(securit
label = ui.label('Checking if the server is online...').classes('text-xl mb-20 whitespace-nowrap text-[3vw]')
cd.text_above = label
with ui.element().classes('w-[50vw] max-h-[75%] aspect-square rounded-full bg-grey text-white flex items-center justify-center whitespace-nowrap text-[3vw] active:scale-95 transition-transform').props("id=recordbutton disabled") as button:
ui.image('/static/microphone.png').classes('h-[75%] w-[75%] object-contain')
ui.image('/static/microphone.png').classes('h-[75%] w-[75%] object-contain').props("id=recordbuttonimage")
button.on('mousedown', lambda: start_recording(client.id))
button.on('mouseup', lambda: stop_recording(client.id))
button.on('touchstart', lambda: start_recording(client.id))

View File

@ -11,6 +11,13 @@ window.addEventListener("load", async (event) => {
await navigator.mediaDevices.getUserMedia({ audio: true });
});
document.getElementById('recordbuttonimage').oncontextmenu = function(event) {
event.preventDefault();
event.stopPropagation(); // not necessary in my case, could leave in case stopImmediateProp isn't available?
event.stopImmediatePropagation();
return false;
};
function startButtonPulse(analyser) {
const button = document.querySelector('#recordbutton');