Class TMenuAccessory

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TMenuAccessory = class(TObject)

Description

Attachment to a specific menu item of TCastleOnScreenMenu, for example may store a value associated with given menu option, and allow to change it by a slider.

Hierarchy

  • TObject
  • TMenuAccessory

Overview

Methods

Public constructor Create;
Public function GetWidth: Integer; virtual; abstract;
Public procedure Draw(const Rectangle: TRectangle); virtual; abstract;
Public function KeyDown(Key: TKey; C: char; ParentMenu: TCastleOnScreenMenu): boolean; virtual;
Public function MouseDown(const MouseX, MouseY: Integer; Button: TMouseButton; const Rectangle: TRectangle; ParentMenu: TCastleOnScreenMenu): boolean; virtual;
Public procedure MouseMove(const NewX, NewY: Integer; const MousePressed: TMouseButtons; const Rectangle: TRectangle; ParentMenu: TCastleOnScreenMenu); virtual;

Properties

Public property OwnedByParent: boolean read FOwnedByParent write FOwnedByParent default true;

Description

Methods

Public constructor Create;
 
Public function GetWidth: Integer; virtual; abstract;

Return the width you will need to display yourself.

Note that this will be asked only from FixItemsRectangles from TCastleOnScreenMenu. So for example TMenuArgument is *not* supposed to return here something based on current TMenuArgument.Value, because we will not query GetWidth after every change of TMenuArgument.Value. Instead, TMenuArgument should return here the width of widest possible Value.

Public procedure Draw(const Rectangle: TRectangle); virtual; abstract;

Draw yourself. Note that Rectangle.Width is for sure the same as you returned in GetWidth.

Public function KeyDown(Key: TKey; C: char; ParentMenu: TCastleOnScreenMenu): boolean; virtual;

This will be called if user will press a key when currently selected item has this TMenuAccessory.

You can use ParentMenu to call ParentMenu.AccessoryValueChanged.

Public function MouseDown(const MouseX, MouseY: Integer; Button: TMouseButton; const Rectangle: TRectangle; ParentMenu: TCastleOnScreenMenu): boolean; virtual;

This will be called if user will click mouse when currently selected item has this TMenuAccessory.

MouseX, Y passed here are in coords where MouseY goes up from the bottom to the top. (This is different than usual window system coords.)

This will be called only if MouseX and MouseY will be within appropriate Rectangle of this accessory. This Rectangle is also passed here, so you can e.g. calculate mouse position relative to this accessory as (MouseX - Rectangle.X0, MouseY - Rectangle.Y0).

Note that while the user holds the mouse clicked (MousePressed <> []), the mouse is "grabbed" by this accessory, and even when the user will move the mouse over other items, they will not receive their MouseDown/MouseMove messages until user will let the mouse go. This prevents the bad situation when user does MouseDown e.g. on "Sound Volume" slider, slides it to the right and then accidentaly moves the mouse also a little down, and suddenly he's over "Music Volume" slider and he changed the position of "Music Volume" slider.

You can use ParentMenu to call ParentMenu.AccessoryValueChanged.

Public procedure MouseMove(const NewX, NewY: Integer; const MousePressed: TMouseButtons; const Rectangle: TRectangle; ParentMenu: TCastleOnScreenMenu); virtual;

This will be called if user will move mouse over the currently selected menu item and menu item will have this accessory.

Just like with MouseDown: This will be called only if NewX and NewY will be within appropriate Rectangle of accessory. You can use ParentMenu to call ParentMenu.AccessoryValueChanged.

Properties

Public property OwnedByParent: boolean read FOwnedByParent write FOwnedByParent default true;

Should this accessory be freed when TCastleOnScreenMenu using it is freed. Useful to set this to False when you want to share one TMenuAccessory across more than one TCastleOnScreenMenu.


Generated by PasDoc 0.13.0 on 2013-08-17 21:27:13