private void handleMouseDown(int modifiersEx) {
        ModelManager modelMgr = ModelManager.getInstance();
        int materialID;
        if ((modifiersEx & MouseEvent.BUTTON1_DOWN_MASK) != 0)
            materialID = modelMgr.getPrimaryMaterialID();
        else if ((modifiersEx & MouseEvent.BUTTON3_DOWN_MASK) != 0)
            materialID = modelMgr.getSecondaryMaterialID();
        else
            return;

        if (selectedX != -1 && selectedY != -1 && modelMgr.getTileAt(selectedX, selectedY) != materialID) {
            if (!modelMgr.isSmartModeOn())
                lastMacroCommand.addCommand(modelMgr.new UpdateTileAtCommand(selectedX, selectedY, materialID));
            else
                lastMacroCommand.addCommand(modelMgr.new SmartUpdateTileAtCommand(selectedX, selectedY, materialID));

        }
    }