KiCad PCB EDA Suite
TEXTENTRY_TRICKS Struct Reference

Add cut/copy/paste to a wxTextEntry instance. More...

#include <textentry_tricks.h>

Static Public Member Functions

static void OnCharHook (wxTextEntry *aTextEntry, wxKeyEvent &aEvent)
 

Static Protected Member Functions

static bool isCtrl (int aChar, const wxKeyEvent &e)
 
static bool isShiftCtrl (int aChar, const wxKeyEvent &e)
 

Detailed Description

Add cut/copy/paste to a wxTextEntry instance.

While these are normally handled without our intervention, this is not always the case.

Definition at line 35 of file textentry_tricks.h.

Member Function Documentation

◆ isCtrl()

static bool TEXTENTRY_TRICKS::isCtrl ( int  aChar,
const wxKeyEvent &  e 
)
staticprotected

◆ isShiftCtrl()

static bool TEXTENTRY_TRICKS::isShiftCtrl ( int  aChar,
const wxKeyEvent &  e 
)
staticprotected

◆ OnCharHook()

void TEXTENTRY_TRICKS::OnCharHook ( wxTextEntry *  aTextEntry,
wxKeyEvent &  aEvent 
)
static

Definition at line 30 of file textentry_tricks.cpp.

31{
32 if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'X' )
33 {
34 aTextEntry->Cut();
35 }
36 else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'C' )
37 {
38 aTextEntry->Copy();
39 }
40 else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'V' )
41 {
42 aTextEntry->Paste();
43 }
44 else if( aEvent.GetKeyCode() == WXK_BACK )
45 {
46 long start, end;
47 aTextEntry->GetSelection( &start, &end );
48
49 if( end > start )
50 {
51 aTextEntry->Remove( start, end );
52 aTextEntry->SetInsertionPoint( start );
53 }
54 else if ( start == end && start > 0 )
55 {
56 aTextEntry->Remove( start-1, start );
57 aTextEntry->SetInsertionPoint( start-1 );
58 }
59 }
60 else if( aEvent.GetKeyCode() == WXK_DELETE )
61 {
62 long start, end;
63 aTextEntry->GetSelection( &start, &end );
64
65 if( end > start )
66 {
67 aTextEntry->Remove( start, end );
68 aTextEntry->SetInsertionPoint( start );
69 }
70 else if( start == end && start < aTextEntry->GetLastPosition() )
71 {
72 aTextEntry->Remove( start, start+1 );
73 }
74 }
75 else
76 {
77 aEvent.Skip();
78 }
79}

Referenced by ACTION_MENU::OnMenuEvent().


The documentation for this struct was generated from the following files: