Menu shortcuts in Unix-based systems - stata

In Stata one can programmatically create a menu entry for a dialogue box or a program as follows:
window menu append item "stUser" "&Pearly's Program" "db myprogram"
In addition, by using the character & before P, a shortcut is also created.
This can subsequently be activated simply by pressing Alt + P.
Nevertheless, as Stata's Resources and Support online FAQ states:
"Note: The ampersand & that appears ... is a Windows-only feature..."
Is there a way to assign shortcuts for menu items in Unix-based
versions of Stata (macOS, Linux)?

The only way I have come up with so far is to assign a shortcut using a function key (say F5):
global F5 "db myprogram;"
Note that the semi-colon tells Stata to also press enter.
For persistent assignment, the aforementioned code line should be included in the profile.do file.
This ensures that it is executed every time Stata starts.

Related

Automatic Code completion in Eclipse 8.4?

I recently installed Eclipse Luna(for win7) for developing C++ programs. The problem is the code completion only shows suggestions when I press Ctrl + Space button. I searched on the internet, but the only solution I was able to find is for old Eclipse(Java) version 3.4 or something. In that you have some text feilds in which you can enter the characters for auto-completion. But in 8.4 there are no such text-fields. Do they have a plugin for this? Please Help me
Yes they've changed the behavior a bit. The auto completion list pops up at entering ., -> or ::, and as you mentioned with CTRL + Space
If the list popped up, press TAB once to get inside the popup selection list, and go up down with the arrow keys. Press enter to select one.
If the entered symbol is specified enough, to select a proposal, hitting Space after the dialog popped up, will autocomplete though.

VC++ Making a single line text box act (mimic a button) on the return key

I am learning Visual C++ 2010 Express on windows XP
This must be a standard task I am trying to do!!!
I have a very basic form with an input text box, an output text box and a button
I enter a value into the input text box and press the button and the answer is displayed in the output text box.
This all works.
I want to press the return key after I have enterd the value into the input textbox (single line box) and have the answer displayed in the output textbox. (the same as pressing the button).
Is this not a simple thing to do?
Any help will be appreciated.
thanks
I hate to break the news, but you are not writing C++ code. The language you are using is called C++/CLI, a managed language that resembles C++ about as well as C# does. The dead give-away is writing code that uses the ^ hat. Easy to see in the code that the GUI designer generates for you.
The Express edition you use is a major cue, it only supports creating GUIs by using C++/CLI. By taking advantage of the Winforms class library and the designer it supports. Very nice, you can plop controls on a form and double click them to implement the default event. Adding the Click event for a button is trivial.
The native way, MFC, is not supported in that edition. And is urky, MFC has no designer support beyond creating dialogs.
Biggest thing about a GUI app is that is does not use the Enter key to move from one control to another. Users are familiar, and know, to press the TAB key instead. The Enter key is reserved to operate the OK button in a dialog.
It is not like you couldn't make it work, Winforms is flexible enough to let you trap the Enter key to change the focus. it is just that you shouldn't, users know when they are not working with a console mode app and are happy to use the TAB key.
Wrong language, wrong UI mode, not what the school you went to told you about, I guess. They don't.

What is difference between hotkey, shortcut and accelerator key?

What is the difference about them?
In Qt, if I have a hotkey for QPushButton, I can make it by "Alt + ?", but if it's for qaction, I can press "?" only
In Windows, an accelerator key is application global; e.g. Alt+F4.
A shortcut key is part of the name of a menu item or button, where it can be underlined, and is available (without modifiers) when that menu item or button is directly available.
From Microsoft:
A hot key is a key combination that the user can press to perform an action quickly. For example, a user can create a hot key that activates a given window and brings it to the top of the z-order.
which seems to indicate that hot keys are system global.
To sum up:
shortcut key = no modifiers, local in menu or (for button) in window
accelerator key = typically with modifier, application global
hot key = apparently system global
I don't know about specific meanings in Qt; for that see the Qt documentation.
Alf's answer is correct for Windows applicability. Your terms you mention (hotkey/shortcut/accelerator) don't sound familiar from a pure Qt point of view.
In Qt you can elect to handle key sequences yourself or you can use Qt's own simplification method. Either way you must remember that Qt itself targets many platforms on which a key combination may or may not make sense. The classic Alt + F4 makes sense on a keyboard, but on a mobile device you don't have an Alt modifier or an F4 key. What you really want is a way of specifying a generic close the application shortcut. This problem is multiplied because the symbol may be available but the key sequence to reach it might be different on other keyboard layouts. This section of the documentation provides a good example.
Qt handles this with class QKeySequence. The very clever Qt developers have provided an easy way of defining common user actions and those actions will use key combinations that are default to the target platform. It does this using enum QKeySequence::StandardKey and in the close the application example, you could use this like so:
QAction exitAction;
exitAction.setShortcut(QKeySequence(QKeySequence::Quit));
This is all explained in the documentation. There are a two other modifiers (shortcutContext() and softKeyRole()) which can be applied to QActions which effect their application in more advanced ways.
You are also free to assign your own shortcuts using something like:
QAction helpAction(tr("&?"));
helpAction.setShortcut(QKeySequence(tr("ALT+?")));
The first line applies the (translated) text "?" to the action which will appear as its text on a menu or button. Note that the question mark symbol might not be the right symbol in all languages so the translate method allows a translator to assign a more appropriate symbol if required. The ampersand symbol means the character immediately after will be the short-cut key when the menu is active.
The second line assigns the (translated) shortcut of Alt + ? and in this example the Shift modifier will be handled by the platform if required. Again, the tr() method allows the translator to specify a more appropriate shortcut if available.
In response to teukkam's comment:
If you mean you simply want your button to be triggerable by a keystroke whether its modified by Alt or not then you could do something like:
QPushButton* yourButton; // assign this pointer yourself
yourButton->setText(tr("&Process"));
yourButton->setShortcut(tr("p"));
In this example, the ampersand in setText() does the same as the previous example, and the translate function is used in the same way.
The setShortcut() method just uses the letter "p" so should work now with or without the Alt modifier. A quick skim of the documentation suggests this will work with or without the Shift modifier as the letters in a key sequence are apparently case-insensitive.
Also, P would be a bad choice as its often assumed to be the print command.
A final note if you're defining hard coded short cuts, make sure they work on all your target platforms!
In Windows:
HotKey
Keyboard key or combination of keys that execute a command in a given context.
Shortcut
Multi-key HotKey with no menu navigation restrictions nor gui elements required.
AccessKey
Single key HotKey which command is to activate a visible command control
(requires gui element) that is captioned/labeled with the corresponding hotkey letter underscored.
Accelerator Keys
Multi-key HotKey which command is to activate a command control (requires gui element) regardless of its visibility.

can I set the AppUserModelID of an arbitrary process launched through a jumplist?

I have a simple console application written in C++ that acts as a stub for launching another application through it's jumplist. Purpose is to add jumplist abilities to applications that do not support this. Call it stub.exe. When running stub.exe it creates a custom jumplist using these steps (taken right form the MS samples):
create an ICustomDestinationList
ICustomDestinationList::BeginList()
create an IObjectCollection
for_each item_to_add
create an IShellLink, set its path/arguments/title/icon
add IShellLink to the IObjectCollection
get the IObjectArray interface from the IObjectCollection
call ICustomDestinationList::AddUserTasks( IObjectArray interface )
ICustomDestinationList::CommitList()
When pinning stub.exe to the taskbar and right-clicking it, the jumpilst appears and it contains all IShellLinks added. When clicking an item, it will launch the corresponding process.
Now I'd like a process launched through this jumplist have it's window(s) grouped under stub.exe's taskbar icon, instead of having it's own group. They key to get this working seems to be the AppUsermodelID. This is what I tried so far:
just for testing, create a couple of shortcuts and set the id through IPropertyStore->SetValue( PKEY_AppUserModel_ID, "id" ). Indeed, when launching these shortcuts, they will all group under the same taskbar icon.
since the shortcuts do what I want, I tried adding shortcuts to stub.exe's jumplist: no effect. The shortcuts don't even show up in the jumplist (maybe one cannot have a shortcut to a shortcut?), yet all methods return S_OK
setting the PKEY_AppUserModel_ID on each of the IShellLinks that get added to the jumplist: no effect
calling ICustomDestinationList->SetAppID(): no effect
instead of using SubTasks, tried with SHAddToRecentDocs: no effect. The recent doc list does not show up. But now things get messy. After setting the AppUserModelID on the shortcut that is responsible for the pinned taskbar item (the one in %APPDATA%/Roaming/Microsoft/Internet Explorer/Quick Launch/User Pinned/TaskBar), the jumplist changed: it does not show the 'Tasks' item anymore, but does show 'Recent' and the items I added using SHAddToRecentDocs. Now when clicking them I get a dialog box with a title that starts with 'd:\desktop' followed by Chinese characters. Hovering the items in the jumplist also shows Chinese characters instead of the descirption I set.
Questions:
What's with the Chinese characters in the jumplist?
How come setting the app id on the taskbar shortcut toggles between 'Tasks' and 'Recent' sections, why are they not both there?
What would be the way, if even possible, to achive what I actually want: a custom jump list of which the items launched will group under it's taskbar icon? (note that the processes I plan to laucnh their do not have their app id set currently)
not much reactions here ;]
In the meantime I managed to solve the main problem myself; it's not quite a straightforward solution but it fullfills the requirements: a program runs in the backround and installs a CBT hook. Each time an application creates a window (HookProc code = HCBT_CREATEWND), the hook checks the application's path against a map containing paths and desired application ids. If a match is found, the application id of the HWND is set. Since this occurs before the window is actually shown and is combined with the custom task list, from a user's point of view the application behaves just like one that does support a recent/pinned document list.

Capturing keyboard input without focus on the programwindow

I am doing a VoIP client and I want to start/stop on WM_KEYDOWN and WM_KEYUP messages for a certain input, say K. When the main window has focus, this is np, but how do I enable it outside of the window? For example, if the window is not in focus and I'm just looking at the desktop or am in a videogame. How does one perform something like this? I am not sure where to begin.
Also -- I guess you somehow has to poll every input even outside the program, is that expensive?
win32 c++ btw
You need to install keyboard hooks: http://msdn.microsoft.com/en-us/library/ms644990(v=VS.85).aspx
This can be very troubling though for every running application if something steals its keyboard messages.
I don't think you want this - if I'm typing a document into Word and I hit K, I'm going to be very angry when your application pops up instead of a "k" appearing in my document.
Windows allows you to assign shortcut keys to an icon on the desktop, but it limits them to the function keys or to combinations containing both Alt and Ctrl. Right-click on a desktop icon and go to Properties, and look for the field marked "Shortcut key".