Skip to content
George Michaelides edited this page May 17, 2015 · 12 revisions

Control Factory

The control factory can be accessed in a GemGui instance. It is instantiated by using the ControlTarget and the IConfigurationResolver. You can provide your own implementation of IConfigurationResolver if you want to override the default control factory.

See the fluent builder for more configuration possibilities.

Button

The button is a plain old button.

           Button Button(int x, int y,
                         int sizeX, int sizeY,
                         Style style,
                         IPattern pattern = null)

TextField

When the TextField is focused, it listens to the keyboard signals and converts them to characters.

 TextField TextField(int x, int y,
                     int sizeX, int sizeY,
                     Color textColor,
                     SpriteFont font,
                     Style style,
                     IHorizontalAlignable horizontalAlignment = null,
                     IVerticalAlignable verticalAlignment = null,
                     IAlignmentTransition alignmentTransition = null,
                     IPattern pattern = null
                     TextAppenderHelper appender = null)

You can provide your own TextAppenderHelper to customise the TextField's behavior

    TextAppenderHelper(KeyboardInputHelper input,
                       char cursor = '_',
                       double cursorFlickInterval = 500.0d,
                       double keyRepeatStartDuration = 0.3d
                       double keyRepeatDuration = 0.003d)

If you want some keys to not be appended, you can intercept the Func<Keys,char,bool> ShouldHandleKey in TextAppenderHelper

This handles all characters except 'a'

  ShouldHandleKey+= (key,convertedChar) => convertedChar!='a';

The TextField has the following events

    event EventHandler<TextFieldEventArgs> OnTextChanged;
    event EventHandler<string> OnTextEntered;

and the following public methods

   void InsertText(string text)
   void RemoveCharacters(int count)

If you wish to add your own key-to-character map, you can use the AddKeyMap(Keys key, string charPair).

If it is two characters, first character is for not holding the shift key, and the second character for holding the shift key.

   Gem.Gui.Input.KeyboarUtils.AddKeyMap(Keys.D1, "1!");

###ListView

The ListView is used to group and align controls

           ListView ListView(int x, int y,
                             int sizeX, int sizeY,
                             Orientation orientation,
                             IHorizontalAlignable horizontalAlignment,
                             IVerticalAlignable verticalAlignment,
                             IAlignmentTransition alignmentTransition,
                             IPattern pattern = null
                             params AControl[] controls)

Clone this wiki locally