-
Notifications
You must be signed in to change notification settings - Fork 179
Open
Description
You have to create statusbar "listening" for Ctrl/Shift+Ins/Del to generate cmCopy, cmPaste, cmCut commands.
Expected behavior: clipboard manipulations work in inputBox out of the box without processing key combinations manually.
Example below, see !!!
comment
#define Uses_TApplication
#define Uses_TEvent
#define Uses_TRect
#define Uses_TDialog
#define Uses_TStaticText
#define Uses_TButton
#define Uses_TMenuBar
#define Uses_TSubMenu
#define Uses_TMenuItem
#define Uses_TStatusLine
#define Uses_TStatusItem
#define Uses_TStatusDef
#define Uses_TDeskTop
#define Uses_TKeys
#define Uses_MsgBox
#include <tvision/tv.h>
#include <string>
const int cmCallInputBox = 100;
const int cmMyAppQuit = cmQuit;
class TInputBoxApp : public TApplication {
public:
TInputBoxApp();
static TMenuBar *initMenuBar(TRect r);
static TStatusLine *initStatusLine(TRect r);
virtual void handleEvent(TEvent& event);
private:
void callInputBoxDemo();
};
TInputBoxApp::TInputBoxApp() :
TProgInit(&TInputBoxApp::initStatusLine,
&TInputBoxApp::initMenuBar,
&TApplication::initDeskTop
)
{
}
TMenuBar* TInputBoxApp::initMenuBar(TRect r) {
r.b.y = r.a.y + 1;
TSubMenu& fileMenu =
*new TSubMenu("~F~ile", kbAltF, hcNoContext);
fileMenu +
*new TMenuItem("Call ~I~nputBox", cmCallInputBox, kbF2, hcNoContext, "F2") +
newLine() +
*new TMenuItem("E~x~it", cmMyAppQuit, kbAltX, hcNoContext, "Alt-X");
return new TMenuBar(r, fileMenu );
}
TStatusLine* TInputBoxApp::initStatusLine(TRect r) {
r.a.y = r.b.y - 1;
return new TStatusLine(r,
*new TStatusDef(0, 0xFFFF) +
*new TStatusItem("~F2~ InputBox", kbF2, cmCallInputBox) +
*new TStatusItem("~Alt-X~ Exit", kbAltX, cmMyAppQuit)
/*
// !!! UNCOMMENT TO ENABLE COPY-PASTE BY KEYBOARD
+
*new TStatusItem(nullptr, kbCtrlIns, cmCopy) +
*new TStatusItem(nullptr, kbShiftIns, cmPaste) +
*new TStatusItem(nullptr, kbShiftDel, cmCut)
*/
);
}
void TInputBoxApp::handleEvent(TEvent& event) {
TApplication::handleEvent(event);
if (event.what == evCommand) {
switch (event.message.command) {
case cmCallInputBox:
callInputBoxDemo();
clearEvent(event);
break;
}
}
}
void TInputBoxApp::callInputBoxDemo() {
char buffer[251];
strcpy(buffer, "Default text");
ushort result = inputBox("Enter Text", "Your input:", buffer, 250);
if (result == cmOK) {
std::string displayText = "Last input: ";
displayText += buffer;
messageBox(displayText.c_str(), mfInformation | mfOKButton);
} else {
messageBox("Input Canceled.", mfInformation | mfOKButton);
}
}
int main() {
TInputBoxApp myApp;
myApp.run();
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels