This diagram shows TTilesView and the functions it inherits from MMouseEventHandler:
The framework calls the MouseDown function whenever a mouse-down event occurs within the area of a TTilesView. The function takes a reference to a TMouseDownEvent, which it uses to determine the location of the mouse down.
The TTilesView::MouseDown function identifies which, if any, tile within the model was clicked on. To do this, the MouseDown function needs to access the data in the model, so it locks the model before accessing the data and releases the model when it is finished. Like the DrawContents function, the MouseDown function can use a TModelPointerTo<AModel> to accomplish this easily.
At this stage in developing the Tiles program, the MouseDown function will only identify whether a specific tile was clicked on. In Step 3 the function will be extended to select the clicked-on tile and issue a command accordingly. To handle the mouse click, the MouseDown function:
02.MouseEvents/Tiles
and launch a Tiles document using TilesTutorialApp
to see the mouse event handling. Make sure that a previous version of a Tiles document is not running when you compile this version. When you click on a tile, the index of that tile is displayed on your AIX console. See "Launching a document" on page 21 for directions on how to compile a project and launch a document.