Hi there
Because my app is an audio player and people are used to start/pause a player with the space bar nowadays, I implemented an Accelerator on the SPACE key. This works as planned so far, but there's also a Textentry for a search, which doesn't get the space key anymore, because (I assume) it's intercepted by the Accelerator.
I tried both types of shortcuts, by Accelerator class and also by Menuitem class, but with the same result.
How can I work around this issue?
Cheers,
Michael
How to handle a SPACE accelerator?
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: How to handle a SPACE accelerator?
Have you considered a separate event handler for OnKeyDown events independently from RapaGUI?
I'm on registered MorphOS using FlowStudio.
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: How to handle a SPACE accelerator?
Which platform is this? Can you provide a MCVE? I can't seem to reproduce the problem.
Re: How to handle a SPACE accelerator?
Sure. I took your Accelerator demo script and added SPACE, LEFT and RIGHT and a textentry. On Windows, you cannot enter a space into the textentry anymore and you cannot navigate in the textentry using left and right arrow keys:
Accelerators.hws (unchanged)
Accelerators.xml with added acc. items and textentry:
So this is a bug, then?
Accelerators.hws (unchanged)
Code: Select all
/****************************************************************
** **
** Name: Accelerators **
** Author: Andreas Falkenhahn **
** Version: 1.0 **
** Date: 06.05.16 **
** Interpreter: Hollywood 6.1 **
** Licence: Sample program **
** Function: Test accelerator keys **
** **
** History: **
** **
** 1.0: (06.05.16) **
** **
** - initial release **
** **
****************************************************************/
/*
** Make sure we have at least Hollywood 6.1!
*/
@VERSION 6,1
/*
** This script requires the RapaGUI plugin
*/
@REQUIRE "RapaGUI"
/*
** Information about this app
*/
@APPTITLE "Accelerator"
@APPVERSION "$VER: Accelerator 1.0 (06.05.16)"
@APPCOPYRIGHT "(C) 2016 Andreas Falkenhahn"
@APPAUTHOR "Andreas Falkenhahn"
@APPDESCRIPTION "Test accelerator keys"
/*
** Handles all incoming events
*/
Function p_EventFunc(msg)
Switch msg.action
Case "RapaGUI":
Switch msg.attribute
Case "Pressed":
Switch msg.id
Case "clear":
moai.DoMethod("lv", "clear")
Case "esc":
End
Default:
If HaveItem(msg, "notifydata")
x$ = msg.notifydata
Else
x$ = UpperStr(msg.id)
EndIf
moai.DoMethod("lv", "insert", "bottom", x$)
moai.DoMethod("lv", "jump", "bottom")
EndSwitch
EndSwitch
EndSwitch
EndFunction
; dynamically create GUI from an external *.xml file definition
moai.CreateApp(FileToString("Accelerators.xml"))
; listen to these events!
InstallEventHandler({RapaGUI = p_EventFunc})
; main loop!
Repeat
WaitEvent
Forever
Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
<accelerator id="accel">
<item id="f1">F1</item>
<item id="f2">F2</item>
<item id="f3">F3</item>
<item id="f4">F4</item>
<item id="f5">F5</item>
<item id="cq" mod="ctrl" notifydata="pressed: Ctrl+Q">Q</item>
<item id="csa" mod="ctrl;shift" notifydata="pressed: Ctrl+Shift+A">A</item>
<item id="ax" mod="alt" notifydata="pressed: Alt+X">X</item>
<item id="cmdw" mod="cmd" notifydata="pressed: CMD+W">W</item>
<item id="esc">ESC</item>
<item id="space">SPACE</item>
<item id="left">LEFT</item>
<item id="right">RIGHT</item>
</accelerator>
<window title="Accelerators" id="win" width="400" accelerator="accel">
<vgroup>
<textentry />
<textview height="250">
Welcome to the accelerator test!\n\n
Please test the following accelerator keys:\n\n
F1\nF2\nF3\nF4\nF5\n
Ctrl+Q\n
Ctrl+Shift+A\n
Alt+X\n
CMD+W (only AmigaOS and Mac OS)\n
ESC to quit
</textview>
<listview id="lv">
<column/>
</listview>
<hgroup>
<button id="clear">Clear</button>
</hgroup>
</vgroup>
</window>
</application>
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: How to handle a SPACE accelerator?
It's a wxWidgets limitation. I've checked back with the wxWidgets team and they say that this is not possible to support in a cross-platform way. It could be made to work on Windows using some tricks but not generally so I'm afraid this can't be changed.