[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Accelerator tricks

Accelerator tricks

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Larkin   (278 posts)  Bio
Date Mon 31 Jan 2011 08:12 PM (UTC)
Message
I'm trying to set up my keypad to change commands based on certain things, and then I want to delete the accelerators or revert them to what they were before. This seems especially tricky, so I'm wondering if I'm missing something here. Keep in mind that this script will be used by others, and I want to keep it general enough to play nice with whatever accelerators they have configured.

1. I have my keypad configured in the Configuration -> Input -> Keypad, but those are not real accelerators. They don't show in AcceleratorList, so I don't know how to grab the commands and save them to be restored later.

2. There seems to be no way to delete an accelerator, such as setting it to nil, and when I use an empty string, it doesn't do anything, though the documentation says it will revert to what it was previously (how does it know?).

3. I have to loop on all the accelerators to get the value for any one macro? Why no lookup table functionality?

I know I can hardcode the keypad accelerators to what I want, but I'm trying to be efficient and user friendly, so any advice?

Thanks.
Top

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 31 Jan 2011 09:01 PM (UTC)
Message

  1. You can find current keypad values with ExportXML. The names to enter to this function will be the ones which appear in the world file XML. Also see table "strKeypadNames" in prefspropertypages.cpp as described below.

  2. Doing what the documentation says removes the "special" accelerator, returning the function of that key to what it originally did. So the simple case would be just to use AcceleratorList to find what ones you added, and just set those ones back to an empty string. If you think this doesn't work can you produce a test case?

  3. The macros are predefined (see the world file). The list will never infrequently change. The actual names are in the source here:

    https://github.com/nickgammon/mushclient/blob/master/dialogs/world_prefs/prefspropertypages.cpp

    Currently around line 1929, or search for "strMacroDescriptions".



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #2 on Mon 31 Jan 2011 09:11 PM (UTC)
Message
Larkin said:
1. I have my keypad configured in the Configuration -> Input -> Keypad, but those are not real accelerators. They don't show in AcceleratorList, so I don't know how to grab the commands and save them to be restored later.

I believe you can use ExportXML(5, "") to get the keypad settings as XML. Then if you're using Lua you can use utils.xmlread() to turn it into a nested Lua table. It should be reasonably easy to turn that back into XML and pass it to ImportXML().

Larkin said:
2. There seems to be no way to delete an accelerator, such as setting it to nil, and when I use an empty string, it doesn't do anything, though the documentation says it will revert to what it was previously (how does it know?).

"what it was previously" likely refers to the keybinding's default, if any. For example, Ctrl+C's default is to copy, and Ctrl+S saves the world.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,863 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]