Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread SelectNext?
Fri, Apr 20 2012 11:38 PMPermanent Link

Jeff Newlin

Lightspeed

This EWB product is very fun for me. I can see lots of possibilities

I'm just getting started and I'm wondering if there is way to have the ENTER key work like the tab key. In good ol' delphi I would us the OnKeyPressed event and use the "SelectNext"  method to move the cursor to the next component.

Is there anything like this for EWB?

Thanks in advance...
jeff
Sat, Apr 21 2012 10:51 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Jeff,

<< This EWB product is very fun for me. I can see lots of possibilities >>

Thanks, it'll be a lot more fun for me when it's released. Wink  But, it
sure looks a lot better than it did over the summer last year.

<< I'm just getting started and I'm wondering if there is way to have the
ENTER key work like the tab key. In good ol' delphi I would us the
OnKeyPressed event and use the "SelectNext"  method to move the cursor to
the next component.

Is there anything like this for EWB? >>

What you want is the FirstControl, NextControl, etc. calls for the
TContainerControl class (WebCtrls unit).  The problem is that they are
currently protected.  However, I'll fix this for the next build/release, and
for now you can fix this yourself in the WebCtrls unit:

  TContainerControl = class(TControl)
     private
        FControls: TObjectList;
        FTabControls: TObjectList;
        FScrollBars: TScrollStyle=ssNone;
        FContainer: THTMLElement;
        FClient: THTMLElement;
        FActiveControl: TControl;
        FFindingControl: Boolean;
        procedure SetScrollBars(Value: TScrollStyle);
        function GetClientHeight: Integer;
        procedure SetClientHeight(Value: Integer);
        function GetClientWidth: Integer;
        procedure SetClientWidth(Value: Integer);
        function GetControlCount: Integer;
        function GetControl(Value: Integer): TControl;
        procedure CreateList;
        procedure FreeList;
        procedure CreateTabList;
        procedure FreeTabList;
     protected
        property ActiveControl: TControl read FActiveControl;
        property Container: THTMLElement read FContainer;
        property Client: THTMLElement read FClient;
        property ControlCount: Integer read GetControlCount;
        property Controls[Index: Integer]: TControl read GetControl;
        function CreateElement: THTMLElement; override;
        procedure InitElement; override;
        procedure RemoveElement; override;
        procedure SetElementColor; override;
        procedure ColorChanged(FromParent: Boolean); override;
        procedure FontChanged(FromParent: Boolean); override;
        procedure HeightChanged; override;
        procedure WidthChanged; override;
        procedure ResetTheme; override;
        function IndexOfControl(Control: TControl): Integer;
        function AddControl(Control: TControl): Integer;
        procedure RemoveControl(Control: TControl);
        procedure SetControlPosition(Control: TControl; NewPos: Integer);
        procedure UpdateControlZIndexes;
        procedure SetActiveControl(Control: TControl);
        function GetControlTabOrder(Control: TControl): Integer;
        procedure SetControlTabOrder(Control: TControl; NewOrder: Integer);
        procedure UpdateControlTabIndexes;
        function WrapTabControls: Boolean; virtual;
        function GetFirstTabControl: TControl; override;
        function GetPriorTabControl(CurControl: TControl): TControl;
override;
        function GetNextTabControl(CurControl: TControl): TControl;
override;
        function GetLastTabControl: TControl; override;
        function CheckKeyDown(Key: Integer; ShiftKey, CtrlKey, AltKey:
Boolean): Boolean; virtual;
        function CheckKeyUp(Key: Integer; ShiftKey, CtrlKey, AltKey:
Boolean): Boolean; virtual;
        function CheckKeyPress(Key: Char; ShiftKey, CtrlKey, AltKey:
Boolean): Boolean; virtual;
     public
        destructor Destroy; override;
        property ClientHeight: Integer read GetClientHeight write
SetClientHeight;
        property ClientWidth: Integer read GetClientWidth write
SetClientWidth;
        property Color;
        property Font;
        property ScrollBars: TScrollStyle read FScrollBars write
SetScrollBars;
        function CanFocus: Boolean; override;
        procedure SetFocus; override;
        procedure Hide; override;
        procedure FirstControl; override;  // Move these calls into the
public section from the protected section
        procedure PriorControl; override;
        procedure NextControl; override;
        procedure LastControl; override;
     end;

Then you can just call NextControl from the OnKeyPress or OnKeyDown event
handlers for the enter key.

I can also see about just adding a property for this in the base TControl
component, which would allow all visual controls to inherit this
functionality properly.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image