本文整理汇总了C++中wxKeyEvent::ControlDown方法的典型用法代码示例。如果您正苦于以下问题:C++ wxKeyEvent::ControlDown方法的具体用法?C++ wxKeyEvent::ControlDown怎么用?C++ wxKeyEvent::ControlDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxKeyEvent
的用法示例。
在下文中一共展示了wxKeyEvent::ControlDown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnKeyDown
void TimeTextCtrl::OnKeyDown(wxKeyEvent &event)
{
event.Skip(false);
int keyCode = event.GetKeyCode();
int digit = mFocusedDigit;
if (mFocusedDigit < 0)
mFocusedDigit = 0;
if (mFocusedDigit >= (int)mDigits.GetCount())
mFocusedDigit = mDigits.GetCount()-1;
// Convert numeric keypad entries.
if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) keyCode -= WXK_NUMPAD0 - '0';
if (keyCode >= '0' && keyCode <= '9') {
mValueString[mDigits[mFocusedDigit].pos] = wxChar(keyCode);
ControlsToValue();
ValueToControls();
mFocusedDigit = (mFocusedDigit+1)%(mDigits.GetCount());
Updated();
}
else if (keyCode == WXK_BACK) {
// Moves left, replaces that char with '0', stays there...
mFocusedDigit--;
mFocusedDigit += mDigits.GetCount();
mFocusedDigit %= mDigits.GetCount();
mValueString[mDigits[mFocusedDigit].pos] = '0';
ControlsToValue();
ValueToControls();
Updated();
}
else if (keyCode == WXK_LEFT) {
mFocusedDigit--;
mFocusedDigit += mDigits.GetCount();
mFocusedDigit %= mDigits.GetCount();
Refresh();
}
else if (keyCode == WXK_RIGHT) {
mFocusedDigit++;
mFocusedDigit %= mDigits.GetCount();
Refresh();
}
else if (keyCode == WXK_HOME) {
mFocusedDigit = 0;
Refresh();
}
else if (keyCode == WXK_END) {
mFocusedDigit = mDigits.GetCount() - 1;
Refresh();
}
else if (keyCode == WXK_UP) {
Increase(1);
Updated();
}
else if (keyCode == WXK_DOWN) {
Decrease(1);
Updated();
}
else if (keyCode == WXK_TAB) {
wxWindow *parent = GetParent();
wxNavigationKeyEvent nevent;
nevent.SetWindowChange(event.ControlDown());
nevent.SetDirection(!event.ShiftDown());
nevent.SetEventObject(parent);
nevent.SetCurrentFocus(parent);
GetParent()->ProcessEvent(nevent);
}
else if (keyCode == WXK_RETURN || keyCode == WXK_NUMPAD_ENTER) {
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
wxWindow *def = tlw->GetDefaultItem();
if (def && def->IsEnabled()) {
wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
def->GetId());
GetParent()->ProcessEvent(cevent);
}
}
else {
event.Skip();
return;
}
if (digit != mFocusedDigit) {
SetFieldFocus(mFocusedDigit);
}
event.Skip(false);
}
示例2: OnKeyEvent
void IWnd_stc::OnKeyEvent(wxKeyEvent& evt)
{
int kc = evt.GetRawKeyCode();
if(kc==wxSTC_KEY_TAB)
{
if(evt.ShiftDown())
{
CmdKeyExecute (wxSTC_CMD_BACKTAB);
}
else
{
CmdKeyExecute (wxSTC_CMD_TAB);
}
return;
}
if(evt.ControlDown())
{
switch(kc)
{
case 'C':
{
Copy();
}
return;
case 'X':
{
Cut();
}
return;
case 'V':
{
Paste();
}
return;
case 'A':
{
SelectAll();
}
return;
case 'Z':
{
Undo();
}
return;
case 'R':
{
Redo();
}
return;
case 'D':
{
this->Clear();
}
return;
//case 'F':
// if(style.get(STYLE_CAN_FIND))
// {
// WndManager::current().evtmgr["Find"].CmdExecuteEx(-1);
// evt.Skip();
// return;
// }
// break;
//case 'H':
// if(style.get(STYLE_CAN_REPLACE))
// {
// WndManager::current().evtmgr["Replace"].CmdExecuteEx(-1);
// evt.Skip();
// return;
// }
// break;
};
}
evt.Skip();
}
示例3: LogKeyEvent
//.........这里部分代码省略.........
case WXK_HOME: key = wxT("HOME"); break;
case WXK_LEFT: key = wxT("LEFT"); break;
case WXK_UP: key = wxT("UP"); break;
case WXK_RIGHT: key = wxT("RIGHT"); break;
case WXK_DOWN: key = wxT("DOWN"); break;
case WXK_SELECT: key = wxT("SELECT"); break;
case WXK_PRINT: key = wxT("PRINT"); break;
case WXK_EXECUTE: key = wxT("EXECUTE"); break;
case WXK_SNAPSHOT: key = wxT("SNAPSHOT"); break;
case WXK_INSERT: key = wxT("INSERT"); break;
case WXK_HELP: key = wxT("HELP"); break;
case WXK_NUMPAD0: key = wxT("NUMPAD0"); break;
case WXK_NUMPAD1: key = wxT("NUMPAD1"); break;
case WXK_NUMPAD2: key = wxT("NUMPAD2"); break;
case WXK_NUMPAD3: key = wxT("NUMPAD3"); break;
case WXK_NUMPAD4: key = wxT("NUMPAD4"); break;
case WXK_NUMPAD5: key = wxT("NUMPAD5"); break;
case WXK_NUMPAD6: key = wxT("NUMPAD6"); break;
case WXK_NUMPAD7: key = wxT("NUMPAD7"); break;
case WXK_NUMPAD8: key = wxT("NUMPAD8"); break;
case WXK_NUMPAD9: key = wxT("NUMPAD9"); break;
case WXK_MULTIPLY: key = wxT("MULTIPLY"); break;
case WXK_ADD: key = wxT("ADD"); break;
case WXK_SEPARATOR: key = wxT("SEPARATOR"); break;
case WXK_SUBTRACT: key = wxT("SUBTRACT"); break;
case WXK_DECIMAL: key = wxT("DECIMAL"); break;
case WXK_DIVIDE: key = wxT("DIVIDE"); break;
case WXK_F1: key = wxT("F1"); break;
case WXK_F2: key = wxT("F2"); break;
case WXK_F3: key = wxT("F3"); break;
case WXK_F4: key = wxT("F4"); break;
case WXK_F5: key = wxT("F5"); break;
case WXK_F6: key = wxT("F6"); break;
case WXK_F7: key = wxT("F7"); break;
case WXK_F8: key = wxT("F8"); break;
case WXK_F9: key = wxT("F9"); break;
case WXK_F10: key = wxT("F10"); break;
case WXK_F11: key = wxT("F11"); break;
case WXK_F12: key = wxT("F12"); break;
case WXK_F13: key = wxT("F13"); break;
case WXK_F14: key = wxT("F14"); break;
case WXK_F15: key = wxT("F15"); break;
case WXK_F16: key = wxT("F16"); break;
case WXK_F17: key = wxT("F17"); break;
case WXK_F18: key = wxT("F18"); break;
case WXK_F19: key = wxT("F19"); break;
case WXK_F20: key = wxT("F20"); break;
case WXK_F21: key = wxT("F21"); break;
case WXK_F22: key = wxT("F22"); break;
case WXK_F23: key = wxT("F23"); break;
case WXK_F24: key = wxT("F24"); break;
case WXK_NUMLOCK: key = wxT("NUMLOCK"); break;
case WXK_SCROLL: key = wxT("SCROLL"); break;
case WXK_PAGEUP: key = wxT("PAGEUP"); break;
case WXK_PAGEDOWN: key = wxT("PAGEDOWN"); break;
case WXK_NUMPAD_SPACE: key = wxT("NUMPAD_SPACE"); break;
case WXK_NUMPAD_TAB: key = wxT("NUMPAD_TAB"); break;
case WXK_NUMPAD_ENTER: key = wxT("NUMPAD_ENTER"); break;
case WXK_NUMPAD_F1: key = wxT("NUMPAD_F1"); break;
case WXK_NUMPAD_F2: key = wxT("NUMPAD_F2"); break;
case WXK_NUMPAD_F3: key = wxT("NUMPAD_F3"); break;
case WXK_NUMPAD_F4: key = wxT("NUMPAD_F4"); break;
case WXK_NUMPAD_HOME: key = wxT("NUMPAD_HOME"); break;
case WXK_NUMPAD_LEFT: key = wxT("NUMPAD_LEFT"); break;
case WXK_NUMPAD_UP: key = wxT("NUMPAD_UP"); break;
case WXK_NUMPAD_RIGHT: key = wxT("NUMPAD_RIGHT"); break;
case WXK_NUMPAD_DOWN: key = wxT("NUMPAD_DOWN"); break;
case WXK_NUMPAD_PAGEUP: key = wxT("NUMPAD_PAGEUP"); break;
case WXK_NUMPAD_PAGEDOWN: key = wxT("NUMPAD_PAGEDOWN"); break;
case WXK_NUMPAD_END: key = wxT("NUMPAD_END"); break;
case WXK_NUMPAD_BEGIN: key = wxT("NUMPAD_BEGIN"); break;
case WXK_NUMPAD_INSERT: key = wxT("NUMPAD_INSERT"); break;
case WXK_NUMPAD_DELETE: key = wxT("NUMPAD_DELETE"); break;
case WXK_NUMPAD_EQUAL: key = wxT("NUMPAD_EQUAL"); break;
case WXK_NUMPAD_MULTIPLY: key = wxT("NUMPAD_MULTIPLY"); break;
case WXK_NUMPAD_ADD: key = wxT("NUMPAD_ADD"); break;
case WXK_NUMPAD_SEPARATOR: key = wxT("NUMPAD_SEPARATOR"); break;
case WXK_NUMPAD_SUBTRACT: key = wxT("NUMPAD_SUBTRACT"); break;
case WXK_NUMPAD_DECIMAL: key = wxT("NUMPAD_DECIMAL"); break;
default:
{
if ( keycode < 128 && wxIsprint((int)keycode) )
key.Printf(wxT("'%c'"), (char)keycode);
else if ( keycode > 0 && keycode < 27 )
key.Printf(_("Ctrl-%c"), wxT('A') + keycode - 1);
else
key.Printf(wxT("unknown (%ld)"), keycode);
}
}
}
wxLogMessage( wxT("%s event: %s (flags = %c%c%c%c)"),
name,
key.c_str(),
event.ControlDown() ? wxT('C') : wxT('-'),
event.AltDown() ? wxT('A') : wxT('-'),
event.ShiftDown() ? wxT('S') : wxT('-'),
event.MetaDown() ? wxT('M') : wxT('-'));
}
示例4: OnKeyDown
void Grid::OnKeyDown(wxKeyEvent &event)
{
switch (event.GetKeyCode())
{
case WXK_LEFT:
case WXK_RIGHT:
{
int rows = GetNumberRows();
int cols = GetNumberCols();
int crow = GetGridCursorRow();
int ccol = GetGridCursorCol();
if (event.GetKeyCode() == WXK_LEFT) {
if (crow == 0 && ccol == 0) {
// do nothing
}
else if (ccol == 0) {
SetGridCursor(crow - 1, cols - 1);
}
else {
SetGridCursor(crow, ccol - 1);
}
}
else {
if (crow == rows - 1 && ccol == cols - 1) {
// do nothing
}
else if (ccol == cols - 1) {
SetGridCursor(crow + 1, 0);
}
else {
SetGridCursor(crow, ccol + 1);
}
}
#if wxUSE_ACCESSIBILITY
// Make sure the NEW cell is made available to the screen reader
mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
#endif
}
break;
case WXK_TAB:
{
int rows = GetNumberRows();
int cols = GetNumberCols();
int crow = GetGridCursorRow();
int ccol = GetGridCursorCol();
if (event.ControlDown()) {
int flags = wxNavigationKeyEvent::FromTab |
( event.ShiftDown() ?
wxNavigationKeyEvent::IsBackward :
wxNavigationKeyEvent::IsForward );
Navigate(flags);
return;
}
else if (event.ShiftDown()) {
if (crow == 0 && ccol == 0) {
Navigate(wxNavigationKeyEvent::FromTab | wxNavigationKeyEvent::IsBackward);
return;
}
else if (ccol == 0) {
SetGridCursor(crow - 1, cols - 1);
}
else {
SetGridCursor(crow, ccol - 1);
}
}
else {
if (crow == rows - 1 && ccol == cols - 1) {
Navigate(wxNavigationKeyEvent::FromTab | wxNavigationKeyEvent::IsForward);
return;
}
else if (ccol == cols - 1) {
SetGridCursor(crow + 1, 0);
}
else {
SetGridCursor(crow, ccol + 1);
}
}
MakeCellVisible(GetGridCursorRow(), GetGridCursorCol());
#if wxUSE_ACCESSIBILITY
// Make sure the NEW cell is made available to the screen reader
mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
#endif
}
break;
case WXK_RETURN:
case WXK_NUMPAD_ENTER:
{
if (!IsCellEditControlShown()) {
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
wxWindow *def = tlw->GetDefaultItem();
if (def && def->IsEnabled()) {
wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
def->GetId());
GetParent()->GetEventHandler()->ProcessEvent(cevent);
//.........这里部分代码省略.........
示例5: OnKeyDown
void wxSymbolListCtrl::OnKeyDown(wxKeyEvent& event)
{
// No keyboard interface for now
event.Skip();
#if 0
// flags for DoHandleItemClick()
int flags = ItemClick_Kbd;
int currentLineNow = SymbolValueToLineNumber(m_current);
int currentLine;
switch ( event.GetKeyCode() )
{
case WXK_HOME:
currentLine = 0;
break;
case WXK_END:
currentLine = GetLineCount() - 1;
break;
case WXK_DOWN:
if ( currentLineNow == (int)GetLineCount() - 1 )
return;
currentLine = currentLineNow + 1;
break;
case WXK_UP:
if ( m_current == wxNOT_FOUND )
currentLine = GetLineCount() - 1;
else if ( currentLineNow != 0 )
currentLine = currentLineNow - 1;
else // currentLineNow == 0
return;
break;
case WXK_PAGEDOWN:
PageDown();
currentLine = GetFirstVisibleLine();
break;
case WXK_PAGEUP:
if ( currentLineNow == (int)GetFirstVisibleLine() )
{
PageUp();
}
currentLine = GetFirstVisibleLine();
break;
case WXK_SPACE:
// hack: pressing space should work like a mouse click rather than
// like a keyboard arrow press, so trick DoHandleItemClick() in
// thinking we were clicked
flags &= ~ItemClick_Kbd;
currentLine = currentLineNow;
break;
#ifdef __WXMSW__
case WXK_TAB:
// Since we are using wxWANTS_CHARS we need to send navigation
// events for the tabs on MSW
{
wxNavigationKeyEvent ne;
ne.SetDirection(!event.ShiftDown());
ne.SetCurrentFocus(this);
ne.SetEventObject(this);
GetParent()->GetEventHandler()->ProcessEvent(ne);
}
// fall through to default
#endif
default:
event.Skip();
currentLine = 0; // just to silent the stupid compiler warnings
wxUnusedVar(currentNow);
return;
}
#if 0
if ( event.ShiftDown() )
flags |= ItemClick_Shift;
if ( event.ControlDown() )
flags |= ItemClick_Ctrl;
DoHandleItemClick(current, flags);
#endif
#endif
}
示例6: OnChar
// kbd handling: notice that we use OnChar() and not OnKeyDown() for
// compatibility here - if we used OnKeyDown(), the programs which process
// arrows themselves in their OnChar() would never get the message and like
// this they always have the priority
void wxScrolledWindow::OnChar(wxKeyEvent& event)
{
int stx, sty, // view origin
szx, szy, // view size (total)
clix, cliy; // view size (on screen)
GetViewStart(&stx, &sty);
GetClientSize(&clix, &cliy);
GetVirtualSize(&szx, &szy);
if( m_xScrollPixelsPerLine )
{
clix /= m_xScrollPixelsPerLine;
szx /= m_xScrollPixelsPerLine;
}
else
{
clix = 0;
szx = -1;
}
if( m_yScrollPixelsPerLine )
{
cliy /= m_yScrollPixelsPerLine;
szy /= m_yScrollPixelsPerLine;
}
else
{
cliy = 0;
szy = -1;
}
int xScrollOld = GetScrollPos(wxHORIZONTAL),
yScrollOld = GetScrollPos(wxVERTICAL);
int dsty;
switch ( event.GetKeyCode() )
{
case WXK_PAGEUP:
case WXK_PRIOR:
dsty = sty - (5 * cliy / 6);
Scroll(-1, (dsty == -1) ? 0 : dsty);
break;
case WXK_PAGEDOWN:
case WXK_NEXT:
Scroll(-1, sty + (5 * cliy / 6));
break;
case WXK_HOME:
Scroll(0, event.ControlDown() ? 0 : -1);
break;
case WXK_END:
Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1);
break;
case WXK_UP:
Scroll(-1, sty - 1);
break;
case WXK_DOWN:
Scroll(-1, sty + 1);
break;
case WXK_LEFT:
Scroll(stx - 1, -1);
break;
case WXK_RIGHT:
Scroll(stx + 1, -1);
break;
default:
// not for us
event.Skip();
return;
}
int xScroll = GetScrollPos(wxHORIZONTAL);
if ( xScroll != xScrollOld )
{
wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, xScroll,
wxHORIZONTAL);
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
}
int yScroll = GetScrollPos(wxVERTICAL);
if ( yScroll != yScrollOld )
{
wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, yScroll,
wxVERTICAL);
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
}
}
示例7: if
void
GlCanvas::OnKeyDown(wxKeyEvent & event)
{
static bool physics = true;
_setCamera();
if (0 == m_pCamera) {
return;
}
vec4 camPosition = m_pCamera->getPropfv(Camera::POSITION);
vec4 camUp = m_pCamera->getPropfv(Camera::NORMALIZED_UP_VEC);
vec4 camView = m_pCamera->getPropfv(Camera::NORMALIZED_VIEW_VEC);
// vec3& camLookAt = m_pCamera->getLookAtPoint();
if ('K' == event.GetKeyCode()) {
m_pEngine->sendKeyToEngine (event.GetKeyCode());
}
if ('M' == event.GetKeyCode()) {
EVENTMANAGER->notifyEvent("NEXT_POSE", "MainCanvas", "", NULL);
}
if ('9' >= event.GetKeyCode() && '0' <= event.GetKeyCode()) {
//m_pEngine->sendKeyToEngine (event.GetKeyCode());
Camera *aCam = RENDERMANAGER->getCamera ("MainCamera");
vec3 v;
switch (event.GetKeyCode()) {
case '1':
v.set (-14.486f * cos (DegToRad (-137.0)) - 59.256 * -sin (DegToRad (-137.0)),
13.266f,
-59.256 * cos (DegToRad(-137.0)) + -14.486f * sin (DegToRad (-137.0)));
aCam->setCamera (vec3 (-14.486f, 13.266f, -59.256f), v, vec3 (0.0f, 1.0f, 0.0f));
break;
case '2':
v.set (0.0f, 0.0f, -1.0f * cos (DegToRad (-141.4f)));
aCam->setCamera (vec3 (7.930f, 16.135f, -38.392f), v, vec3 (0.0f, 1.0f, 0.0f));
break;
case '3':
v.set (0.0f, 0.0f, -1.0f * cos (DegToRad (-81.8f)));
aCam->setCamera (vec3 (7.374f, 14.465f, -58.637f), v, vec3 (0.0f, 1.0f, 0.0f));
break;
case '4':
v.set (0.0f, 0.0f, -1.0f * cos (DegToRad (-17.0f)));
aCam->setCamera (vec3 (13.363f, 13.977f, -47.436f), v, vec3 (0.0f, 1.0f, 0.0f));
break;
case '5':
v.set (0.0f, 0.0f, -1.0f * cos (DegToRad (135.58f)));
aCam->setCamera (vec3 (-131.176f, 9.555f, 188.927f), v, vec3 (0.0f, 1.0f, 0.0f));
break;
}
}
if ('B' == event.GetKeyCode()) {
m_pEngine->sendKeyToEngine (event.GetKeyCode());
}
if ('P' == event.GetKeyCode()) {
m_pEngine->sendKeyToEngine (event.GetKeyCode());
}
float direction;
if (true == m_pCamera->isDynamic()) {
direction = VELOCITY;
}
else {
direction = NON_DYNAMIC_VELOCITY;
}
if (true == event.ShiftDown()) { // SHIFT = fast motion
direction *= 10.0f;
}
else if (true == event.ControlDown()) { // CTRL = very fast motion. note: shift has precedence over control!
direction *= 100.0f;
}
if ('S' == event.GetKeyCode()) {
if (true == m_pCamera->isDynamic()) {
vec4 vel (camView);
//vel *= 2.0f;
//vel -= m_OldCamView;
//m_OldCamView.set (vel.x, vel.y, vel.z);
vel.y = 0.0f;
//.........这里部分代码省略.........
示例8: onKeyDown
//.........这里部分代码省略.........
// Hide call tip if showing
if (call_tip->IsShown())
call_tip->Show(false);
// Hide F+R panel if showing
else if (panel_fr && panel_fr->IsShown())
showFindReplacePanel(false);
}
// Check for up/down keys while calltip with multiple arg sets is open
if (call_tip->IsShown() && ct_function && ct_function->nArgSets() > 1 && !ct_dwell)
{
if (e.GetKeyCode() == WXK_UP)
{
call_tip->prevArgSet();
handled = true;
}
else if (e.GetKeyCode() == WXK_DOWN)
{
call_tip->nextArgSet();
handled = true;
}
}
#ifdef __WXMSW__
Colourise(GetCurrentPos(), GetLineEndPosition(GetCurrentLine()));
#endif
#ifdef __APPLE__
if (!handled) {
const int keyCode = e.GetKeyCode();
const bool shiftDown = e.ShiftDown();
if (e.ControlDown()) {
if (WXK_LEFT == keyCode) {
if (shiftDown) {
HomeExtend();
}
else {
Home();
}
handled = true;
}
else if (WXK_RIGHT == keyCode) {
if (shiftDown) {
LineEndExtend();
}
else {
LineEnd();
}
handled = true;
}
else if (WXK_UP == keyCode) {
if (shiftDown) {
DocumentStartExtend();
}
else {
DocumentStart();
}
handled = true;
}
else if (WXK_DOWN == keyCode) {
if (shiftDown) {
示例9: OnKeyEvent
void BetProcedureFrame::OnKeyEvent(wxKeyEvent& event) {
int code = event.GetKeyCode();
bool special = false;
//set focus
if (code == 'v' || code == 'V') {
m_txtVoltage->SetFocus();
special = true;
}
if (code == 'd' || code == 'D') {
m_txtDuration->SetFocus();
special = true;
}
if (code == 'c' || code == 'C') {
m_txtCurrent->SetFocus();
special = true;
}
//switches
if (code >= 0x154 && code <= 0x159 && state_ == STATE_INITIAL) {
DoSwitchChange(code - 0x154); //0...5
special = true;
}
//currents limit
if (code >= 0x31 && code <= 0x36 && event.ControlDown()) {
int cur = code - 0x31;
switch (cur) {
case 0:
m_txtLimitCur1->SetFocus();
break;
case 1:
m_txtLimitCur2->SetFocus();
break;
case 2:
m_txtLimitCur3->SetFocus();
break;
case 3:
m_txtLimitCur4->SetFocus();
break;
case 4:
m_txtLimitCur5->SetFocus();
break;
case 5:
m_txtLimitCur6->SetFocus();
break;
}
special = true;
}
//start procedure
if (code == 's' || code == 'S') {
if (state_ == STATE_INITIAL && validate())
DoStart();
if (state_ == STATE_RUNNING)
DoGoInFinishing();
special = true;
}
//increase values
if ((code == 0x184 || code == 0x3d) && state_ == STATE_RUNNING) { //'+'
wxWindow* focusWnd = wxWindow::FindFocus();
if (focusWnd == m_txtVoltage) {
float value = std::atof(m_txtVoltage->GetValue()) + VOLTAGE_LOW_INCREMENT;
if (value > VOLTAGE_LIMIT)
value = VOLTAGE_LIMIT;
DoUpdateVoltage(value);
}
if (focusWnd == m_txtCurrent) {
int value = std::atoi(m_txtCurrent->GetValue()) + CURRENT_INCREMENT;
if (value > CURRENT_LIMIT)
value = CURRENT_LIMIT;
DoUpdateCurrent(value);
}
if (focusWnd == m_txtDuration) {
int value = std::atoi(m_txtDuration->GetValue()) * 60 + DURATION_INCREMENT;
if (value > DURATION_LIMIT)
value = DURATION_LIMIT;
DoUpdateDuration(value);
}
special = true;
}
//decrease values
if ((code == 0x2d) && state_ == STATE_RUNNING) { //'-'
wxWindow* focusWnd = wxWindow::FindFocus();
if (focusWnd == m_txtVoltage) {
float value = std::atof(m_txtVoltage->GetValue()) - VOLTAGE_LOW_DECREMENT;
if (value < 0)
value = 0;
DoUpdateVoltage(value);
}
if (focusWnd == m_txtCurrent) {
int value = std::atoi(m_txtCurrent->GetValue()) - CURRENT_DECREMENT;
if (value < 0)
value = 0;
DoUpdateCurrent(value);
}
if (focusWnd == m_txtDuration) {
int value = std::atoi(m_txtDuration->GetValue()) * 60 - DURATION_DECREMENT;
if (value < 0)
value = 0;
DoUpdateDuration(value);
}
special = true;
//.........这里部分代码省略.........
示例10: OnKeyDown
void wxListCtrlEx::OnKeyDown(wxKeyEvent& event)
{
if (!m_prefixSearch_enabled)
{
event.Skip();
return;
}
int code = event.GetKeyCode();
if (code == WXK_LEFT ||
code == WXK_RIGHT ||
code == WXK_UP ||
code == WXK_DOWN ||
code == WXK_HOME ||
code == WXK_END)
{
ResetSearchPrefix();
event.Skip();
return;
}
if (event.AltDown() && !event.ControlDown()) // Alt but not AltGr
{
event.Skip();
return;
}
wxChar key;
switch (code)
{
case WXK_NUMPAD0:
case WXK_NUMPAD1:
case WXK_NUMPAD2:
case WXK_NUMPAD3:
case WXK_NUMPAD4:
case WXK_NUMPAD5:
case WXK_NUMPAD6:
case WXK_NUMPAD7:
case WXK_NUMPAD8:
case WXK_NUMPAD9:
key = '0' + code - WXK_NUMPAD0;
break;
case WXK_NUMPAD_ADD:
key = '+';
break;
case WXK_NUMPAD_SUBTRACT:
key = '-';
break;
case WXK_NUMPAD_MULTIPLY:
key = '*';
break;
case WXK_NUMPAD_DIVIDE:
key = '/';
break;
default:
key = 0;
break;
}
if (key)
{
if (event.GetModifiers())
{
// Numpad keys can not have modifiers
event.Skip();
}
HandlePrefixSearch(key);
return;
}
#if defined(__WXMSW__)
if (code >= 300 && code != WXK_NUMPAD_DECIMAL)
{
event.Skip();
return;
}
// Get the actual key
BYTE state[256];
if (!GetKeyboardState(state)) {
event.Skip();
return;
}
wxChar buffer[1];
int res = ToUnicode(event.GetRawKeyCode(), 0, state, buffer, 1, 0);
if (res != 1)
{
event.Skip();
return;
}
key = buffer[0];
if (key < 32)
{
event.Skip();
return;
}
if (key == 32 && event.HasModifiers())
//.........这里部分代码省略.........
示例11: OnKey
void ProsodyDisplay::OnKey(wxKeyEvent& event)
{//========================================
PHONEME_LIST *p;
int display=1;
if(selected_ph < 0)
selected_ph = 0;
p = &phlist[selected_ph];
switch(event.GetKeyCode())
{
case WXK_F2:
// make and play from this clause
MakeWave2(phlist,numph);
break;
case WXK_LEFT:
if(selected_ph > 1)
selected_ph--;
break;
case WXK_RIGHT:
if(selected_ph < (numph-2))
selected_ph++;
break;
case WXK_UP:
if(event.ControlDown())
ChangePh(-1,2);
else
ChangePh(1,0);
display = 1;
break;
case WXK_DOWN:
if(event.ControlDown())
ChangePh(1,-2);
else
ChangePh(-1,0);
break;
case ',':
case '<':
if(p->length > 0)
p->length--;
break;
case '.':
case '>':
p->length++;
break;
case WXK_TAB:
display = 0;
event.Skip();
transldlg->SetFocus();
break;
default:
display = 0;
event.Skip();
break;
}
if(display)
{
Refresh();
SelectPh(selected_ph);
}
} // end of ProsodyDisplay::OnKey
示例12: OnChar
void wxListBox::OnChar(wxKeyEvent& event)
{
if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER)
{
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
if ( tlw && tlw->GetDefaultItem() )
{
wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
if ( def && def->IsEnabled() )
{
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
event.SetEventObject(def);
def->Command(event);
return ;
}
}
event.Skip() ;
}
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) )
{
// FIXME: look in ancestors, not just parent.
wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ;
if (win)
{
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
new_event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( new_event );
}
}
else if ( event.GetKeyCode() == WXK_TAB )
{
wxNavigationKeyEvent new_event;
new_event.SetEventObject( this );
new_event.SetDirection( !event.ShiftDown() );
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
new_event.SetWindowChange( event.ControlDown() );
new_event.SetCurrentFocus( this );
if ( !GetEventHandler()->ProcessEvent( new_event ) )
event.Skip() ;
}
else if ( event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_UP )
{
// perform the default key handling first
wxControl::OnKeyDown( event ) ;
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
event.SetEventObject( this );
wxArrayInt aSelections;
int n, count = GetSelections(aSelections);
if ( count > 0 )
{
n = aSelections[0];
if ( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );
else if ( HasClientUntypedData() )
event.SetClientData( GetClientData(n) );
event.SetString(GetString(n));
}
else
{
n = -1;
}
event.SetInt(n);
GetEventHandler()->ProcessEvent(event);
}
else
{
if ( event.GetTimestamp() > m_lastTypeIn + 60 )
{
m_typeIn = wxEmptyString ;
}
m_lastTypeIn = event.GetTimestamp() ;
m_typeIn += (char) event.GetKeyCode() ;
int line = FindString(wxT("*")+m_typeIn+wxT("*")) ;
if ( line >= 0 )
{
if ( GetSelection() != line )
{
SetSelection(line) ;
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
event.SetEventObject( this );
if ( HasClientObjectData() )
event.SetClientObject( GetClientObject( line ) );
else if ( HasClientUntypedData() )
event.SetClientData( GetClientData(line) );
event.SetString(GetString(line));
event.SetInt(line);
GetEventHandler()->ProcessEvent(event);
}
}
}
}
示例13: OnChar
void FrequencyDialog::OnChar(wxKeyEvent& event) {
int c = event.GetKeyCode();
long long freq;
std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();
switch (c) {
case WXK_RETURN:
case WXK_NUMPAD_ENTER:
// Do Stuff
freq = strToFrequency(dialogText->GetValue().ToStdString());
if (targetMode == FDIALOG_TARGET_DEFAULT) {
if (activeDemod) {
activeDemod->setTracking(true);
activeDemod->setFollow(true);
activeDemod->setFrequency(freq);
activeDemod->updateLabel(freq);
} else {
wxGetApp().setFrequency(freq);
}
}
if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
if (lastDemodType == "USB" || lastDemodType == "LSB") {
freq *= 2;
}
if (activeDemod) {
activeDemod->setBandwidth(freq);
} else {
wxGetApp().getDemodMgr().setLastBandwidth(freq);
}
}
Close();
break;
case WXK_ESCAPE:
Close();
break;
}
std::string allowed("0123456789.MKGHZmkghz");
if (allowed.find_first_of(c) != std::string::npos || c == WXK_DELETE || c == WXK_BACK || c == WXK_NUMPAD_DECIMAL
|| (c >= WXK_NUMPAD0 && c <= WXK_NUMPAD9)) {
#ifdef __linux__
dialogText->OnChar(event);
event.Skip();
#else
event.DoAllowNextEvent();
#endif
} else if (event.ControlDown() && c == 'V') {
// Alter clipboard contents to remove unwanted chars
wxTheClipboard->Open();
wxTextDataObject data;
wxTheClipboard->GetData(data);
std::string clipText = data.GetText().ToStdString();
std::string pasteText = filterChars(clipText, std::string(allowed));
wxTheClipboard->SetData(new wxTextDataObject(pasteText));
wxTheClipboard->Close();
event.Skip();
} else if (c == WXK_RIGHT || c == WXK_LEFT || event.ControlDown()) {
event.Skip();
}
}
示例14: OnKeyEvent
void OnCompletionBox::OnKeyEvent(wxKeyEvent& event)
{
const int keyCode = event.GetKeyCode();
switch (keyCode)
{
case WXK_DELETE:
case WXK_NUMPAD_DELETE:
{
//try to delete the currently selected config history item
int pos = this->GetCurrentSelection();
if (0 <= pos && pos < static_cast<int>(this->GetCount()) &&
//what a mess...:
(GetValue() != GetString(pos) || //avoid problems when a character shall be deleted instead of list item
GetValue().empty())) //exception: always allow removing empty entry
{
const auto selValue = utfCvrtTo<Zstring>(GetString(pos));
if (std::find(history_.begin(), history_.end(), selValue) != history_.end()) //only history elements may be deleted
{
//save old (selected) value: deletion seems to have influence on this
const wxString currentVal = this->GetValue();
//this->SetSelection(wxNOT_FOUND);
//delete selected row
erase_if(history_, [&](const Zstring& item) { return item == selValue; });
SetString(pos, wxString()); //in contrast to Delete(), this one does not kill the drop-down list and gives a nice visual feedback!
//Delete(pos);
//(re-)set value
SetValue(currentVal);
}
return; //eat up key event
}
}
break;
case WXK_UP:
case WXK_NUMPAD_UP:
case WXK_DOWN:
case WXK_NUMPAD_DOWN:
case WXK_PAGEUP:
case WXK_NUMPAD_PAGEUP:
case WXK_PAGEDOWN:
case WXK_NUMPAD_PAGEDOWN:
return; //swallow -> using these keys gives a weird effect due to this weird control
}
#ifdef ZEN_MAC
//copy/paste is broken on wxCocoa: http://trac.wxwidgets.org/ticket/14953 => implement manually:
assert(CanCopy() && CanPaste() && CanCut());
if (event.ControlDown())
switch (keyCode)
{
case 'C': //Command + C
Copy();
return;
case 'V': //Command + V
Paste();
return;
case 'X': //Command + X
Cut();
return;
}
#endif
event.Skip();
}
示例15: onKeyDown
/* TextEditor::onKeyDown
* Called when a key is pressed
*******************************************************************/
void TextEditor::onKeyDown(wxKeyEvent& e)
{
// Check if keypress matches any keybinds
wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers()));
// Go through matching binds
bool handled = false;
for (unsigned a = 0; a < binds.size(); a++)
{
string name = binds[a];
// Open/update calltip
if (name == "ted_calltip")
{
updateCalltip();
handled = true;
}
// Autocomplete
else if (name == "ted_autocomplete")
{
// Get word before cursor
string word = GetTextRange(WordStartPosition(GetCurrentPos(), true), GetCurrentPos());
// If a language is loaded, bring up autocompletion list
if (language)
{
autocomp_list = language->getAutocompletionList(word);
AutoCompShow(word.size(), autocomp_list);
}
handled = true;
}
// Find/replace
else if (name == "ted_findreplace")
{
showFindReplaceDialog();
handled = true;
}
// Find next
else if (name == "ted_findnext")
{
wxCommandEvent e;
onFRDBtnFindNext(e);
handled = true;
}
// Jump to
else if (name == "ted_jumpto")
{
openJumpToDialog();
handled = true;
}
}
#ifdef __WXMSW__
Colourise(GetCurrentPos(), GetLineEndPosition(GetCurrentLine()));
#endif
#ifdef __APPLE__
if (!handled) {
const int keyCode = e.GetKeyCode();
const bool shiftDown = e.ShiftDown();
if (e.ControlDown()) {
if (WXK_LEFT == keyCode) {
if (shiftDown) {
HomeExtend();
}
else {
Home();
}
handled = true;
}
else if (WXK_RIGHT == keyCode) {
if (shiftDown) {
LineEndExtend();
}
else {
LineEnd();
}
handled = true;
}
else if (WXK_UP == keyCode) {
if (shiftDown) {
DocumentStartExtend();
}
else {
DocumentStart();
}
handled = true;
}
//.........这里部分代码省略.........