MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / GUIHandleEvent

Method GUIHandleEvent

LibLemon/src/gui/window.cpp:179–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177 }
178
179 void Window::GUIHandleEvent(LemonEvent& ev){
180 switch(ev.event){
181 case EventMousePressed:
182 {
183 lastMousePos = ev.mousePos;
184
185 if(menuBar && ev.mousePos.y < menuBar->GetFixedBounds().height){
186 rootContainer.active = nullptr;
187 menuBar->OnMouseDown(ev.mousePos);
188 } else if (menuBar){
189 //ev.mousePos.y -= menuBar->GetFixedBounds().height;
190 }
191
192 timespec newClick;
193 clock_gettime(CLOCK_BOOTTIME, &newClick);
194
195 if((newClick.tv_nsec / 1000000 + newClick.tv_sec * 1000) - (lastClick.tv_nsec / 1000000 + lastClick.tv_sec * 1000) < 600){ // Douuble click if clicks less than 600ms apart
196 rootContainer.OnDoubleClick(ev.mousePos);
197
198 newClick.tv_nsec = 0;
199 newClick.tv_sec = 0; // Prevent a third click from being registerd as a double click
200 } else {
201 rootContainer.OnMouseDown(ev.mousePos);
202 }
203
204 lastClick = newClick;
205 }
206 break;
207 case EventMouseReleased:
208 lastMousePos = ev.mousePos;
209
210 if(menuBar && ev.mousePos.y < menuBar->GetFixedBounds().height){
211 rootContainer.active = nullptr;
212 menuBar->OnMouseDown(ev.mousePos);
213 } else if (menuBar){
214 //ev.mousePos.y -= menuBar->GetFixedBounds().height;
215 }
216
217 rootContainer.OnMouseUp(ev.mousePos);
218 break;
219 case EventRightMousePressed:
220 lastMousePos = ev.mousePos;
221
222 if(menuBar && ev.mousePos.y < menuBar->GetFixedBounds().height){
223 rootContainer.active = nullptr;
224 menuBar->OnMouseDown(ev.mousePos);
225 } else if (menuBar){
226 //ev.mousePos.y -= menuBar->GetFixedBounds().height;
227 }
228
229 rootContainer.OnRightMouseDown(ev.mousePos);
230 break;
231 case EventRightMouseReleased:
232 lastMousePos = ev.mousePos;
233
234 if(menuBar && ev.mousePos.y < menuBar->GetFixedBounds().height){
235 rootContainer.active = nullptr;
236 menuBar->OnMouseDown(ev.mousePos);

Callers 14

mainFunction · 0.80
DisplayMessageBoxFunction · 0.80
FileDialogFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
PollMenuFunction · 0.80
mainFunction · 0.80

Calls 9

GetFixedBoundsMethod · 0.80
OnDoubleClickMethod · 0.80
OnRightMouseDownMethod · 0.80
OnKeyPressMethod · 0.80
OnCommandMethod · 0.80
OnMouseDownMethod · 0.45
OnMouseUpMethod · 0.45
OnRightMouseUpMethod · 0.45
OnMouseMoveMethod · 0.45

Tested by

no test coverage detected