MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / handle

Method handle

src/csvgrid.cpp:67–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67int CsvGrid::handle(int event) {
68 DEBUG_PRINTF("#### CsvGrid::handle event=%d\n", event);
69 if( !areEventsAllowed() )
70 return(Fl_Table::handle(event));
71 int row_top, col_left, row_bot, col_right;
72 int R, C;
73 get_selection(row_top, col_left, row_bot, col_right);
74 R = row_top;
75 C = col_left;
76
77 switch (event) {
78 case FL_KEYBOARD: // key press in table?
79 if( Fl::event_key() == FL_Tab && !Fl::event_command() && !Fl::event_ctrl() && !Fl::event_alt() ) {
80 // TAB
81 doneEditing();
82 if( Fl::event_shift() ) {
83 if( C == 0 && C == col_edit && R > 0 ) {
84 // SHIFT-TAB pressed while in the left-most column
85 R--;
86 C = dataTable->getNumberCols() - 1;
87 } else if (C > 0 ){
88 C--;
89 }
90 } else {
91 if( C == dataTable->getNumberCols()-1 && C == col_edit && R < dataTable->getNumberRows()-1 ) {
92 // TAB pressed while in the right-most column
93 R++;
94 C = 0;
95 } else if (C < dataTable->getNumberCols()-1 ){
96 C++;
97 }
98 }
99 updateSelection(R,C,R,C); // select the current cell
100 setVisibleArea( R, C );
101 if( dataTable->cellContainsLineBreak(R,C) ) {
102 app.editSingleCell();
103 } else {
104 startEditing(R,C); // start new edit
105 }
106 return(1);
107 } else if( Fl::event_key() == FL_Enter && !Fl::event_command() && !Fl::event_shift() && !Fl::event_ctrl() && !Fl::event_alt() ) {
108 // ENTER
109 doneEditing(); // finish any previous editing
110 updateSelection(R, C, R, C); // select the current cell
111 if( dataTable->cellContainsLineBreak(R,C) ) {
112 app.editSingleCell();
113 } else {
114 startEditing(R,C); // start new edit
115 if (Fl::event() == FL_KEYBOARD && Fl::e_text[0] != '\r') {
116 input->handle(Fl::event()); // pass keypress to input widget
117 }
118 }
119 return(1);
120 } else if( Fl::event_key() >= 32 && Fl::event_key() <= 126 && !Fl::event_command() && !Fl::event_alt() && !Fl::event_ctrl() ) {
121 // [druckbares Zeichen]
122 updateSelection(R, C, R, C); // select the current cell
123 startEditing(R,C); // start new edit
124 if (Fl::event() == FL_KEYBOARD && Fl::e_text[0] != '\r') {

Callers

nothing calls this directly

Calls 6

getNumberColsMethod · 0.80
getNumberRowsMethod · 0.80
editSingleCellMethod · 0.80
showDefaultStatusMethod · 0.80
getTopWindowMethod · 0.80
cellContainsLineBreakMethod · 0.45

Tested by

no test coverage detected