class ObjectClicked(Condition):
    instances = None
    click = None

    def created(self):
        parameter = self.get_parameter(0)
        self.click = parameter.click
        self.objectInfo = self.get_parameter(1).objectInfo
        self.player.mouse.enable_mouse(self.objectInfo)
        for handle in self.resolve_objects(self.objectInfo):
            self.player.mouse.enable_mouse(handle)
            if parameter.double:
                self.player.frame.add_handlers(
                    handle, on_double_click=self.on_mouse_press)
            else:
                self.player.frame.add_handlers(
                    handle, on_mouse_press=self.on_mouse_press)
            self.player.frame.add_no_sleep_instance(handle)
        self.instances = GeneratedInstances(self)

    def on_mouse_press(self, instance, button, modifiers):
        click = self.click
        if click == LEFT_CLICK and button != mouse.LEFT:
            return
        elif click == MIDDLE_CLICK and button != mouse.MIDDLE:
            return
        elif click == RIGHT_CLICK and button != mouse.RIGHT:
            return
        self.instances.add_instance(instance)
        if self.isTriggered:
            self.generate()

    def check(self):
        return self.instances.check(self.objectInfo)
示例#2
0
class ObjectClicked(Condition):
    instances = None
    click = None
    def created(self):
        parameter = self.get_parameter(0)
        self.click = parameter.click
        self.objectInfo = self.get_parameter(1).objectInfo
        self.player.mouse.enable_mouse(self.objectInfo)
        for handle in self.resolve_objects(self.objectInfo):
            self.player.mouse.enable_mouse(handle)
            if parameter.double:
                self.player.frame.add_handlers(handle,
                    on_double_click = self.on_mouse_press)
            else:
                self.player.frame.add_handlers(handle,
                    on_mouse_press = self.on_mouse_press)
            self.player.frame.add_no_sleep_instance(handle)
        self.instances = GeneratedInstances(self)
    
    def on_mouse_press(self, instance, button, modifiers):
        click = self.click
        if click == LEFT_CLICK and button != mouse.LEFT:
            return
        elif click == MIDDLE_CLICK and button != mouse.MIDDLE:
            return
        elif click == RIGHT_CLICK and button != mouse.RIGHT:
            return
        self.instances.add_instance(instance)
        if self.isTriggered:
            self.generate()
    
    def check(self):
        return self.instances.check(self.objectInfo)
 def created(self):
     parameter = self.get_parameter(0)
     self.click = parameter.click
     self.objectInfo = self.get_parameter(1).objectInfo
     self.player.mouse.enable_mouse(self.objectInfo)
     for handle in self.resolve_objects(self.objectInfo):
         self.player.mouse.enable_mouse(handle)
         if parameter.double:
             self.player.frame.add_handlers(
                 handle, on_double_click=self.on_mouse_press)
         else:
             self.player.frame.add_handlers(
                 handle, on_mouse_press=self.on_mouse_press)
         self.player.frame.add_no_sleep_instance(handle)
     self.instances = GeneratedInstances(self)
示例#4
0
 def created(self):
     parameter = self.get_parameter(0)
     self.click = parameter.click
     self.objectInfo = self.get_parameter(1).objectInfo
     self.player.mouse.enable_mouse(self.objectInfo)
     for handle in self.resolve_objects(self.objectInfo):
         self.player.mouse.enable_mouse(handle)
         if parameter.double:
             self.player.frame.add_handlers(handle,
                 on_double_click = self.on_mouse_press)
         else:
             self.player.frame.add_handlers(handle,
                 on_mouse_press = self.on_mouse_press)
         self.player.frame.add_no_sleep_instance(handle)
     self.instances = GeneratedInstances(self)