Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread TBrowser and OnMouseWheel
Sun, Jan 1 2017 12:17 PMPermanent Link

Uli Becker

I have some forms with heights bigger than the screen height. Vertical
scrollbar of the surface is enabled.

In order to scroll by using the mouse wheel when the mouse is over the
form, I use this code, which works fine:

procedure THomeForm.HomeFormMouseWheel(Sender: TObject; WheelDelta:
Integer; ShiftKey, CtrlKey, AltKey: Boolean; X, Y: Integer);
begin
   Application.Surface.ScrollBy(0,WheelDelta);
end;

But when the form contains a TBrowser control (and the mouse is over
this control), that doesn't work any more even if scrolling of the
TBrowser control is disabled.

Is there a way to achieve that?

Thanks Uli
Wed, Jan 4 2017 2:51 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< But when the form contains a TBrowser control (and the mouse is over this control), that doesn't work any more even if scrolling of the TBrowser control is disabled. >>

What are the contents of the TBrowser ?  Is it just an HTML document, or does it use JS also ?

If the contents of the TBrowser control are "eating" the mouse wheel events, then there's not much that can be done.   Also, this behavior is largely up to each browser, and the behavior of each browser may vary.  I think that the normal expected behavior is that the scrolling occurs until it can't occur anymore, and then any other mouse wheel events are forwarded up to the outer parent document.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jan 4 2017 4:15 PMPermanent Link

Uli Becker

Tim,

> What are the contents of the TBrowser ?  Is it just an HTML document, or does it use JS also ?

It's just HTML.

> If the contents of the TBrowser control are "eating" the mouse wheel events, then there's not much that can be done.   Also, this behavior is largely up to each browser, and the behavior of each browser may vary.  I think that the normal expected behavior is that the scrolling occurs until it can't occur anymore, and then any other mouse wheel events are forwarded up to the outer parent document.

Probably I was messing up something. In a simple test project the
scrolling with the same document works as expected. I'll have to check
that out in detail

Thanks anyway.

Uli
Thu, Jan 5 2017 3:28 AMPermanent Link

Uli Becker

Tim,

> If the contents of the TBrowser control are "eating" the mouse wheel events, then there's not much that can be done.

OK, that's what I found out:

1. In an application I have many forms higher than the screen.
2. I don't set "ViewPort.OverflowY := otAuto"
3. I do set "Surface.Scrollbars := sbVertical"

Doing so I have no problems to center messageboxes etc.

Since scrolling of the Surface (by using the mouse-wheel) only works
when the mouse is over the surface, I use the OnMouseWheel event of each
form to scroll the surface:

Application.Surface.Scrollby(0,WheelDelta);

That works fine and for me it's better than to scroll the viewport.

4. When I put a TBrowser control on a form, the OnMouseWheel event is
not fired any more when the mouse is over the TBrowser control.
Regardless of the content of the browser control (even if it's empty).

If I decide to change everything and scroll the viewport: how can a
messagbox be centered on the visible screen? No problem to customize the
messagebox, but how do I get the correct x,y?

Thanks very much

Uli
Thu, Jan 5 2017 4:07 AMPermanent Link

Uli Becker

Tim,

in addition to my last post:

I now tried to set the form's vertical scrollbar and didn't change the
surface's height.
Scrolling of the form works as expected, but even then it's not possible
to scroll by using the mouse wheel when the mouse is over the (empty or
not) TBrowser control.

Is there really no way to change this behaviour?

Thanks Uli
Thu, Jan 5 2017 4:21 AMPermanent Link

Matthew Jones

Uli Becker wrote:

> Scrolling of the form works as expected, but even then it's not possible to scroll by using the mouse wheel when the mouse is over the (empty or not) TBrowser control.

You want the mouse wheel to scroll the embedded browser, or the main form? Surely this is all down to how the browser behaves, so you should be looking at that and it's capabilities. Then, if possible, how to make it work in EWB. But having the mouse wheel scroll what it is over is standard, so not sure why it would be available as an option.

What happens when you have a lot of content that can be scrolled in the TBrowser?

--

Matthew Jones
Thu, Jan 5 2017 4:49 AMPermanent Link

Uli Becker

Matthew,

> You want the mouse wheel to scroll the embedded browser, or the main form? Surely this is all down to how the browser behaves, so you should be looking at that and it's capabilities. Then, if possible, how to make it work in EWB. But having the mouse wheel scroll what it is over is standard, so not sure why it would be available as an option.

I want to scroll the surface / form, not the embedded browser. The whole
thing works by using  ViewPort.OverflowY := otAuto and setting the
surface's constraint.min.height.

I'll stay with that way.

> But having the mouse wheel scroll what it is over is standard,

That's true, but in TBrowser you can disable scrolling. But as Tim said:
if the browser eats the onMouseWheel event, then there's not much that
can be done.

BTW: To answer my own question:

<< No problem to customize the messagebox, but how do I get the correct
x,y? >>

Viewport.Height and Viewport.Width just do it. Smile

Thanks Uli
Image