Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread ActiveForm, ActiveControl, MouseControl and RemoveFocus
Mon, Oct 26 2015 3:38 PMPermanent Link

Christian Kaufmann

Some questions I already asked, but they may be lost in other questions. So I ask these again.

1) I can use Application.Surface.ActiveForm but I didn't find an "ActiveControl" to get the
information, which control currently has focus?

2) When I open a dialog, none of the TEdit controls has input focus. But as soon as I clicked in
one, I cannot remove the focus anymore. RemoveFocus has no effect and I cannot do something like
"ActiveControl := nil".

3) I need to know the control at the currents mouse cursor position.

Can somebody help me here?

Thanks.

cu Christian
Mon, Oct 26 2015 3:51 PMPermanent Link

Raul

Team Elevate Team Elevate

On 10/26/2015 3:38 PM, Christian Kaufmann wrote:
> 1) I can use Application.Surface.ActiveForm but I didn't find an "ActiveControl" to get the
> information, which control currently has focus?

I'd suggest you loop thru all controls until you hit one with the
"Focused = True"

> 2) When I open a dialog, none of the TEdit controls has input focus. But as soon as I clicked in
> one, I cannot remove the focus anymore. RemoveFocus has no effect and I cannot do something like
> "ActiveControl := nil".

Did you turn off TabStop for all the TEdit controls ? That's the only
way i can see how one would avoid one of them getting the focus (and you
also kill keyboard navigation with this).

Calling RemoveFocus works fine here - for example i have a timer that
calls "Edit1.RemoveFocus" and focus gets removed from TEdit that has the
focus.

It might help if you described what you're trying to accomplish - you
seem to fighting some "normal" behavior here and some of the way to
achieve might not result in a good user experience.


> 3) I need to know the control at the currents mouse cursor position.

Pretty sure Tim answered this and it was "not at this time".

Raul
Mon, Oct 26 2015 4:56 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Christian,

<< 1) I can use Application.Surface.ActiveForm but I didn't find an "ActiveControl" to get the information, which control currently has focus? >>

There isn't such a property at this time.  There is this property:

http://www.elevatesoft.com/manual?action=viewprop&id=ewb2&comp=TControl&prop=ActiveControl

but it only applies to the parent control, not the entire application.

<< 2) When I open a dialog, none of the TEdit controls has input focus. But as soon as I clicked in
one, I cannot remove the focus anymore. RemoveFocus has no effect and I cannot do something like
"ActiveControl := nil". >>

How are you calling RemoveFocus - via a button click, etc. ?

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Oct 27 2015 2:09 AMPermanent Link

Christian Kaufmann

Tim Young [Elevate Software] wrote:

> http://www.elevatesoft.com/manual?action=viewprop&id=ewb2&comp=TControl&prop=ActiveControl
>
> but it only applies to the parent control, not the entire application.

I tried using Application.Surface.ActiveForm.ActiveControl and this works. All I have to do are
some checks on Assigned()


> How are you calling RemoveFocus - via a button click, etc. ?

I tried this:

procedure TFEntryClubEditDlg.FEntryClubEditDlgShow(Sender: TObject);
begin
 if Assigned(ActiveControl)
   then ActiveControl.RemoveFocus;
end;

In some dialogs I prefere no focus on any control in order to avoid accidental deletion of a value
e.g. by pressing space.


And there is still my open question about how to find the control at the current mouse cursor
position.

cu Christian
Tue, Oct 27 2015 5:15 AMPermanent Link

Matthew Jones

Raul wrote:

> Did you turn off TabStop for all the TEdit controls ? That's the only
> way i can see how one would avoid one of them getting the focus (and
> you also kill keyboard navigation with this).
>
> Calling RemoveFocus works fine here - for example i have a timer that
> calls "Edit1.RemoveFocus" and focus gets removed from TEdit that has
> the focus.
>
> It might help if you described what you're trying to accomplish - you
> seem to fighting some "normal" behavior here and some of the way to
> achieve might not result in a good user experience.

I suspect there is some other way to get the focus to fail, as that is
what is happening for me too. I'm doing nothing abnormal, but the focus
is not set at the start. I've not had time to investigate yet.

--

Matthew Jones
Tue, Oct 27 2015 12:52 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Christian,

<< I tried using Application.Surface.ActiveForm.ActiveControl and this works. All I have to do are
some checks on Assigned() >>

I added a TSurface.ActiveControl property for the next build.  It's undocumented for now, but will do what you want.

<< And there is still my open question about how to find the control at the current mouse cursor position. >>

I already answered this: there is no function that does what you want right now, so you'll have to roll your own or wait.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Oct 27 2015 1:21 PMPermanent Link

Christian Kaufmann

> I added a TSurface.ActiveControl property for the next build.  It's undocumented for now, but
> will do what you want.

Great, thanks.


> I already answered this: there is no function that does what you want right now, so you'll have
> to roll your own or wait.

I was already thinking of that. The main problem I see is that I don't have a global OnMouseMove
event. I found the global singleton TEventManager but I don't see a way to "hook in" without
changing the EWB library code.

cu Christian
Image