MCPcopy Create free account
hub / github.com/KLayout/klayout / key_event

Method key_event

src/laybasic/laybasic/layMove.cc:113–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113bool
114MoveService::key_event (unsigned int key, unsigned int buttons)
115{
116 if (lay::EditorServiceBase::key_event (key, buttons)) {
117 return true;
118 }
119
120 if (buttons == 0 && (key == lay::KeyEnter || key == lay::KeyReturn)) {
121 finish_move ();
122 return true;
123 }
124
125 double dx = 0.0, dy = 0.0;
126 if (int (key) == lay::KeyDown) {
127 dy = -1.0;
128 } else if (int (key) == lay::KeyUp) {
129 dy = 1.0;
130 } else if (int (key) == lay::KeyLeft) {
131 dx = -1.0;
132 } else if (int (key) == lay::KeyRight) {
133 dx = 1.0;
134 }
135
136 if (! m_dragging && fabs (dx + dy) > 0.0 && mp_editables->has_selection ()) {
137
138 // determine a shift distance which is 2, 5 or 10 times the grid and is more than 5 pixels
139 double dmin = double (5 /*pixels min shift*/) / ui ()->mouse_event_trans ().mag ();
140 double d = m_global_grid;
141 while (d < dmin) {
142 d *= 2.0;
143 if (d < dmin) {
144 d *= 2.5;
145 if (d < dmin) {
146 d *= 2.0;
147 }
148 }
149 }
150
151 db::DVector s = db::DVector (dx * d, dy * d);
152 m_shift += s;
153
154 std::string pos = std::string ("dx: ") + tl::micron_to_string (m_shift.x ()) + " dy: " + tl::micron_to_string (m_shift.y ());
155 mp_view->message (pos);
156
157 mp_editables->transform (db::DCplxTrans (s));
158
159 return true;
160
161 } else {
162 return false;
163 }
164}
165
166bool
167MoveService::shortcut_override_event (unsigned int key, unsigned int buttons)

Callers 1

send_key_press_eventMethod · 0.45

Calls 10

key_eventFunction · 0.85
micron_to_stringFunction · 0.85
mouse_event_transMethod · 0.80
yMethod · 0.80
uiFunction · 0.70
stringFunction · 0.50
has_selectionMethod · 0.45
xMethod · 0.45
messageMethod · 0.45
transformMethod · 0.45

Tested by

no test coverage detected