Example #1
0
 def _ns_other_event(self, ns_event):
     #print "PyGUI_NS_EventHandler._ns_other_event for", self ###
     event = Event(ns_event)
     component = self.pygui_component
     if component:
         #print "...passing", event.kind, "to", component ###
         component.handle_event(event)
Example #2
0
 def ns_process_key_event(self, ns_event):
     #  Perform menu setup before command-key events.
     #  Send non-command key events to associated window if any,
     #  otherwise pass them to the pygui application. This is necessary
     #  because otherwise there is no way of receiving key events when
     #  there are no windows.
     if ns_event.modifierFlags() & NSCommandKeyMask:
         NSApplication.sendEvent_(self._ns_app, ns_event)
     else:
         ns_window = ns_event.window()
         if ns_window:
             ns_window.sendEvent_(ns_event)
         else:
             event = Event(ns_event)
             self.handle(event.kind, event)
Example #3
0
def win_message_to_event(message, target=None):
    hwnd, msg, wParam, lParam, milliseconds, gpos = message
    kind, button = win_message_map[msg]
    time = milliseconds / 1000.0
    if kind == 'mouse_move' and wParam & win_button_flags <> 0:
        kind = 'mouse_drag'
    if target:
        lpos = target.global_to_local(gpos)
    else:
        lpos = gpos
    event = Event()
    event.kind = kind
    event.global_position = gpos
    event.position = lpos
    event.time = time
    event.button = button
    shift = api.GetKeyState(wc.VK_SHIFT) & 0x80 <> 0
    control = api.GetKeyState(wc.VK_CONTROL) & 0x80 <> 0
    option = api.GetKeyState(wc.VK_MENU) & 0x80 <> 0
    event.shift = event.extend_contig = shift
    event.control = event.extend_noncontig = control
    event.option = option
    vkey = None
    if kind == 'mouse_down':
        global win_last_mouse_down
        last = win_last_mouse_down
        if last and last.button == button and time - last.time <= win_dbl_time:
            x0, y0 = last.global_position
            x1, y1 = gpos
            if abs(x1 - x0) <= win_dbl_xdist and abs(y1 - y0) <= win_dbl_ydist:
                event.num_clicks = last.num_clicks + 1
        win_last_mouse_down = event
    elif kind == 'key_down' or kind == 'key_up':
        event.unichars = ui.TranslateVirtualKey(wParam)
        event.char = event.unichars.decode('ascii')
        event._keycode = wParam
        if wParam == 0x0d:
            if (lParam & 0x1000000):
                event.key = 'enter'
            else:
                event.key = 'return'
        else:
            event.key = win_special_keys.get(wParam) or event.char
        if kind == 'key_down':
            event.auto = lParam & win_prev_key_state <> 0
    return event
Example #4
0
 def _ns_mouse_event_to_event(self, ns_event):
     event = Event(ns_event)
     event.position = tuple(self._ns_event_position(ns_event))
     return event