Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 14 total
Thread Z Order and Focus
Thu, Oct 22 2015 10:06 PMPermanent Link

Rick

Tim

I have a TDialog which is the parent of multiple dynamically created
TPanels. Each TPanel is the parent of a TMultiLineEdit which is
positioned top-left and stretched bottom-right in the TPanel.

The TPanels overlap each other and can be moved around via the mouse by
clicking on their caption bars.

I know that there are issues with focus on some controls but what I'm
seeing is that clicking in the client area of a TPanel gives it focus
but does not bring it to the front of other TPanels. This activates the
clicked TMultiLineEdit and shows the caret but does not bring the TPanel
to the top of the z order.

I can drag another TPanel over the top of the active panel but the focus
does not change and the caret of the active TMultiLineEdit shows through
the TPanel which is over the top of it.

So, two problems here:

1. Clicking the client area of a TPanel does not bring it to the top of
the z order. Clicking the caption bar does.

2. The TMultiLineEdit that currently has focus retains focus even if
anther TPanel is brought to the top and overlays it. The caret bleeds
through.

Is this working as designed or could something be done to make it
function a bit more as expected?

The following OnCreate event can be added to a TDialog to show the effect.

uses WebCtnrs, WebEdits;

procedure TForm1.Form1Create(Sender: TObject);
var
  i: integer;
  p: TPanel;
begin
  for i:=1 to 10 do
    begin
      p:=TPanel.Create(Self);
      p.Left:=Trunc(Random*Self.ClientWidth);
      p.Top:=Trunc(Random*Self.ClientHeight);
      p.Width:=200;
      p.Height:=200;
      p.Client.Background.Fill.Color:=clRed;
      with TMultiLineEdit.Create(p) do
        begin
          Layout.Position:=lpTopLeft;
          Layout.Stretch:=lsBottomRight;
        end;
    end;
end;

--
Rick
Fri, Oct 23 2015 2:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Rick,

<< 1. Clicking the client area of a TPanel does not bring it to the top of the z order. Clicking the caption bar does. >>

This is as-designed - only forms assume that they should be brought to the front with a click.  If you want it to behave differently, then you need to use the panel's OnClick to call BringToFront.

The caption bar click brings the panel to front because it starts dragging it, per your request to make it do so. Smile

<< 2. The TMultiLineEdit that currently has focus retains focus even if anther TPanel is brought to the top and overlays it. The caret bleeds through. >>

This is a function of the browser (IE is a serial offender here).  It's ugly, but there's not much I can do about it.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Oct 23 2015 6:47 PMPermanent Link

Rick

On 24/10/15 05:23, Tim Young [Elevate Software] wrote:
> This is as-designed - only forms assume that they should be brought to the front with a click.  If you want it to behave differently, then you need to use the panel's OnClick to call BringToFront.

Yeah, but what if you have a child component on the panel and you want
the whole thing to come to the front if you click on that? I'm looking
for desktop style functionality here. I know mobile is all the rage but
not everyone finds that platform very productive.

> The caption bar click brings the panel to front because it starts dragging it, per your request to make it do so. Smile

So you would prefer not to support dragging and therefore not allow
z-order change when clicking?

> This is a function of the browser (IE is a serial offender here).  It's ugly, but there's not much I can do about it.

Except, of course, if the panel was brought to the front when clicking
on a child within it, just like in a desktop application. This would fix
the ugliness.

--
Rick
Sat, Oct 24 2015 6:44 AMPermanent Link

Uli Becker

Rick,

> Yeah, but what if you have a child component on the panel and you want
> the whole thing to come to the front if you click on that?

How about:

procedure TForm1.MultiLineEdit1Enter(Sender: TObject);
begin
   TPanel(TMultiLineEdit(Sender).Parent).BringToFront;
end;

Uli
Sat, Oct 24 2015 4:39 PMPermanent Link

Rick

On 24/10/15 21:44, Uli Becker wrote:
> How about:
>
> procedure TForm1.MultiLineEdit1Enter(Sender: TObject);
> begin
>     TPanel(TMultiLineEdit(Sender).Parent).BringToFront;
> end;

Yes, sure can do it that way but the TPanel may be a composite control
with several children and this type of processing would have to be done
for all of them. That's the approach I have to take now.

Perhaps if controls could have multiple events (e.g. OnEnter, OnClick,
etc.) assigned then it might be simpler.

--
Rick
Wed, Oct 28 2015 4:12 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Rick,

I added a new ActivateOnClick property to the TControl class that will allow for this.  It is protected, but published for all of the container classes.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Nov 12 2015 9:20 AMPermanent Link

Rick

On 29/10/15 07:12, Tim Young [Elevate Software] wrote:
> I added a new ActivateOnClick property to the TControl class that will allow for this.  It is protected, but published for all of the container classes.
>

Tim, the ActivateOnClick property works well in EWB 2.03, thanks for
adding it.

However there still seems to be an issue when clicking the caption bar.
This brings the control (form or panel) to the front as before but
doesn't set focus to any client control. This means the problem of the
cursor bleeding through top most controls in IE still occurs and causes
a bit of confuses as to which control actually has focus.

Is there anything I can do to trap a click event for the caption bar? I
can define a click event for the caption bar but it doesn't seem to
fire. Failing this, is there any other way of switching focus to the top
most control when clicking the caption bar of a form or panel?

--
Rick
Fri, Nov 13 2015 7:33 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Rick,

<< However there still seems to be an issue when clicking the caption bar. This brings the control (form or panel) to the front as before but doesn't set focus to any client control. >>

The best I can probably do here is something like an OnActivate event that will allow you to trap the bring-to-front action and focus the desired control.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Nov 13 2015 8:10 AMPermanent Link

Rick

On 13/11/15 23:33, Tim Young [Elevate Software] wrote:
> << However there still seems to be an issue when clicking the caption bar. This brings the control (form or panel) to the front as before but doesn't set focus to any client control. >>
>
> The best I can probably do here is something like an OnActivate event that will allow you to trap the bring-to-front action and focus the desired control.
>

Tim, an OnActivate event would be a very welcome addition anyway
regardless of the focus issue.

However, if you know that the form/panel is being activated (you must if
you are going to fire an OnActivate) then why not maintain a
last-focused control property internally for container controls?
Something like this must happen for Windows type applications so that
the last focused child control regains focus when its parent is
activated (e.g. via caption bar click).

It seemed to work this way in EWB1. Clicking the caption bar of a form
brought it to the front and set focus to the last focused control on the
form so I'm assuming that information must have been maintained
somewhere. If the form/panel/container has no child controls then I'm
not sure what would gain focus...perhaps the client area of the container?

Was there a reason why EWB2 moved away from this type of window
management that EWB supported?

I'm probably sounding pretty archaic but a familiar windowing
environment for desktop style applications, even in a browser, goes a
long way when it comes to productivity. I know that infrastructure bloat
can be an issue but, as a developer, the more that EWB can do for me the
more I can stay focused on my actual application.

--
Rick
Fri, Nov 13 2015 5:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Rick,

<< However, if you know that the form/panel is being activated >>

The issue is right there: "form/panel" is not correct, it's just "form" in EWB 2.  In EWB 1.x, TForm descended from TPanel, but in EWB 2.x, a panel is just a container, and does not contain "form functionality" such as auto-focusing the last active control, etc.  It's this way because it's assumed that a panel is not an "end-all-be-all" container like a form, rather just one control of many others on a form.

If you look at the source code to the TFormControl (WebForms unit), you'll see this functionality (FocusLastActiveControl, etc.).

Tim Young
Elevate Software
www.elevatesoft.com
Page 1 of 2Next Page »
Jump to Page:  1 2
Image