Go to QuArK Web Site
Mouse in the Map View
Updated 05 Apr 2018
Upper levels:
QuArK Information Base
4. The Source Code
4.4. Specific Topics

 4.4.4. Mouse in the Map View

 [ Prev - Up - Next ] 

Processing mouse events (moves, drags and clicks) is distributed between the Python and Delphi components of QuArK. The mapview control (see 'Methods of Map View controls') is basically in charge of it all. When a map or model editor is launched, mapview controls get associated with certain areas of the screen. These have an onmouse callback function, which is assigned to a Python-defined function by a line like this (from quarkpy.qbaseeditor):

        v.onmouse = self.mousemap
Every time the mouse is moved, the mousemap function of 'self' (an editor) is called. For editors as defined in qbaseeditor, the mousemap function starts out like this:
    def mousemap(self, view, x, y, flags, handle):
where 'flags' is a string containing information about what buttons were depressed, and handle is any handle that the mouse is over. The flags string doesn't indicate directly what key was pressed, but rather codes functions, mediated by the 'Map -> Mouse' setup options.

For clicks, the real processing is done by the MouseClicked function, which is defined by the editor's HandlesModule (maphandles for the map editor), which itself calls the mapview method Clicktarget. This latter is defined in Delphi, and calls the AnalyseClic methods of the various kinds of map objects to find out if the click was 'over' each object in the map. These methods take as parameter a List, to which they add the click-ed on stuff they find.

A bit oddly, the map editor's MouseClicked method calls on the qhandle MouseClicked method for some processing, I'm not sure why it's set up this way, but anyway Python is responsible for the 'drill thru' selection model whereby the top thing is selected first, then the one under that, etc, and quite a lot of selection behavior can be manipulated in Python.


Copyright (c) 2022, GNU General Public License by The QuArK (Quake Army Knife) Community - https://quark.sourceforge.io/

 [ Prev - Top - Next ]