Jump to content
Sign in to follow this  
chrs

RscControlsGroup, Text Box with Scroll Bar Script. How to?

Recommended Posts

        class b_textScrollBox: RscControlsGroup
        {
            idc = -1;
            text = ""; //--- ToDo: Localize;
            x = 0.371094 * safezoneW + safezoneX;
            y = 0.654 * safezoneH + safezoneY;
            w = 0.381563 * safezoneW;
            h = 0.341 * safezoneH;
            class Controls
            {
                class b_textBox: RscStructuredText
                {
                    idc = 1000;
                    text = "b_textBox"; //--- ToDo: Localize;
                    x = 0.291094 * safezoneW + safezoneX;
                    y = 0.22 * safezoneH + safezoneY;
                    w = 0.381563 * safezoneW;
                    h = 0.341 * safezoneH;
                };
            };
        };

Hi,

 

I'm trying to create a script that will expand the RscStructuredText text box above's height dynamically based on the text passed to the script.

 

For example:
0 = ["this is some test text..."] execVM "addText.sqf";

 

So far Ive figured out how to expand and shrink the height of the text box. For an example of what I mean this script would double the height of the RscStructuredText control:

_t = _this select 0;
(_display displayCtrl 1000) ctrlSetStructuredText (parseText _t);
_pos = ctrlPosition (_display displayCtrl 1000);
_height = 2 * (_pos select 3);
(_display displayCtrl 1000) ctrlSetPosition [(_pos select 0),(_pos select 1),(_pos select 2),_height];
(_display displayCtrl 1000) ctrlCommit 0;

However I'd like to expand the height with precision so the scroll bar only goes to the bottom on the text.


Could anyone point me in the right direction?

 

Thanks.

Share this post


Link to post
Share on other sites

Found a solution, and since Ive seen similar questions to mine asked many times when searching the internet but no answers I'll post my findings here.

 

I found a function called BIS_Fnc_DiaryHints and use it as an example to create this, but just like the dairy it breaks down if you input too much text. Hopefully this helps someone else get to grips with control groups quicker:

// Find control
disableSerialization;

_display = findDisplay 8600;
_ctrlStructuredText = (_display displayCtrl 1000);

// Generate a lot of structured text for testing purposes
_t = "Start... ";
for "_i" from 0 to 180 do {
    _t = _t + "This is a random sentence.";
};
_t = _t + " ...End";

// Set the structured text
_ctrlStructuredText ctrlSetStructuredText (parseText _t);

// Manipulate the controls height
_ctrlPos = ctrlPosition _ctrlStructuredText;
_ctrlPos set [3,(ctrltextheight _ctrlStructuredText) min (safezoneH - (_ctrlPos select 1) + 0.13)];
(_display displayCtrl 1000) ctrlSetPosition _ctrlPos;
(_display displayCtrl 1000) ctrlCommit 0;

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×