524 views
in GUI Development by

https://ask.embedded-wizard.de/?qa=blob&qa_blobid=3271941659236094894

I having a Text in my project.

The content inside the text are dynamic.

So if we are allocating more content to the text, need to enable the scroll bar and if we scroll the scroll bar

we need to display the hided contents of text on scrolling.

1 Answer

0 votes
by

Hello mvg,

you will need to implement glue code between the Text view and the Scrollbar. The glue code takes care of (1) initializing the Scrollbar with scroll ranges corresponding to the Text view and (2) handling events when the user interacts with the scrollbar and so scroll the the Text view content. Following are the steps:

Step 1: In your project the Text view has the property Ellipsis set true. This will cause the view to truncate the text to the visible portion only. Scrolling is not possible in such case. Please set Ellipsis to false.

Step 2: Add a new slot method to your component and name it for example onUpdateText.

Step 3: Assign the slot method to Text view's property OnUpdate. See also the chapter Arrange other views on the content of the Text view.

Step 4: Implement the slot method with following code (see also the chapter Determine the scrollbar's current scroll position and scroll range):

VerticalScrollbar.ContentArea =  Text.GetContentArea().h;
VerticalScrollbar.ViewArea    =  Text.Bounds.h;
VerticalScrollbar.Position    = -Text.ScrollOffset.y;

Now, the scrollbar is updated automatically when the content of the Text view has changed.

Step 5: Add a new slot method to your component and name it for example onScroll.

Step 6: Assign the slot method to Scrollbar's property OnScroll. See also the chapter Implement scrollbar's slot methods.

Step 7: Implement the slot method with following code (see also Scroll the text within the Text view area):

Text.ScrollOffset.y = -VerticalScrollbar.Position;

Now, when the user drags on the scrollbar, the scroll offset in the Text view is adjusted accordingly.

I hope it helps you further.

Best regards

Paul Banach

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...