BIS fnc initListNBoxSorting: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "True" to "true")
m (Text replacement - "[[Image:" to "[[File:")
 
(25 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Function|Comments=
{{RV|type=function
____________________________________________________________________________________________


| arma3 |Game name=
|game1= arma3
|version1= 1.56


|1.56|Game version=
|gr1= GUI


|gr1= GUI |GROUP1=
|descr= [[File:A3_BIS_fnc_initListNBoxSorting_example.jpg|thumb|right|A GUI using [[BIS_fnc_initListNBoxSorting]]]]
____________________________________________________________________________________________
Automatically creates buttons and sets them up so they can be used to sort a [[CT_LISTNBOX]]. The buttons will automatically be resized to fit the column width of '''ctrlFilter'''.


| Automatically creates buttons and sets them up so they can be used to sort a [[CT_LISTNBOX]]. The buttons will automatically be resized to the column width of given <tt>controlFilter</tt>.
By default, the '''ctrlContent''' columns are sorted by [[lnbText]] (using [[lnbSort]]). If a specific column should be sorted by [[lnbValue]] (using [[lnbSortByValue]]) instead, then something needs to be set in the data of the corresponding '''ctrlFilter''' column (literally ''something'', the condition in the source code is <sqf inline>(_ctrlFilter lnbData [0, _i]) != ""</sqf>).
{{Informative|
* '''controlFilter'''
** x, y, w and h define where the buttons for sorting are created
** It should be placed above the <tt>controlFilter</tt>
** The amount of columns and their size should be identical with the onces of <tt>controlFilter</tt>.
** The text set in the columns is displayed as text for the buttons (The buttons are transparent actually). Icons which indicate how the list is currently sorted are also adjusted when the button is pressed.
** If a column of <tt>controlContent</tt> is supposed to be sorted by '''value''' instead of '''data''' (default), then something needs to be set in the data of corresponding <tt>controlFilter</tt> column
** The control can also be part of a [[CT_CONTROLS_GROUP]], if that's the case, the buttons will be created as children of  that group
** To keep a uniform style between vanilla controls and custom ones it's advisable to create a background with [[CT_STATIC]] behind the <tt>controlFiilter</tt> with </tt>colorBackground[] {{=}} {0,0,0,1};</tt>}}
[[Image:A3_BIS_fnc_initListNBoxSorting_example.jpg|400px|thumb|center|Example GUI using this function]]
|Description=
____________________________________________________________________________________________


| [controlFilter, controlContent, columnIndexes, idc] call [[BIS_fnc_initListNBoxSorting]] |Syntax=
Regarding '''ctrlFilter''':
* The position and size of this control define where the buttons for sorting are created, thus it should be placed above '''ctrlContent''' and its columns should have the same size as the columns of '''ctrlContent'''.
* The text set in the columns is displayed as text for the buttons (the buttons are actually transparent).
* The control can also be part of a [[CT_CONTROLS_GROUP]]. If that is the case, the buttons will be created as children of that group.
* To keep a uniform style between vanilla and custom controls it is recommended to create a background with [[CT_STATIC]] behind '''ctrlFilter''' with <syntaxhighlight lang="cpp" inline>colorBackground[] = { 0, 0, 0, 1 };</syntaxhighlight>.
See {{Link|CT_LISTNBOX#BIS_fnc_initListNBoxSorting Example}} for a full example including a config.


|p1= controlFilter: [[Control]] - Dummy [[CT_LISTNBOX]] control used for setting up the filter. If parameter is [[controlNull]] function will show an error message.|PARAMETER1=
|s1= [ctrlFilter, ctrlContent, columnIndexes, idc] call [[BIS_fnc_initListNBoxSorting]]


|p2= controlContent: [[Control]] - The [[CT_LISTNBOX]] which actually contains the content. If parameter is [[controlNull]] function will show an error message. |PARAMETER2=
|p1= ctrlFilter: [[Control]] - dummy [[CT_LISTNBOX]] control used for setting up the filter.


|p3= columnIndexes: [[Array]] - Array of [[Number|numbers]]. These are the indexes of the <tt>controlContent</tt> which should be filterable/sortable |PARAMETER3=
|p2= ctrlContent: [[Control]] - the [[CT_LISTNBOX]] which actually contains the sortable content.


|p4= idc: [[Number]] - (Optional, default 200) Will be used to assign idcs to the buttons which are automatically created. First button has <tt>idc</tt>, second button <tt>idc + 1</tt> and so on |PARAMETER4=
|p3= columnIndexes: [[Array]] of [[Number]]s - (Optional, default: []) these are the column indexes of ''ctrlContent'' which should be sortable. An empty array means all columns are sortable.


| [[Boolean]] - [[true]] on success, otherwise [[false]] |Return value=
|p4= idc: [[Number]] - (Optional, default: 200) used to assign IDCs to the buttons created by this function. The first button has '''idc''', the second button has '''idc''' + 1 and so on.
____________________________________________________________________________________________


|x1= <code>[_lnbFilter, _lnbContent, [0,1,2,3]] [[call]] [[BIS_fnc_initListNBoxSorting]];</code> |Example 1=
|r1= [[Boolean]] - [[true]] on success, otherwise [[false]]
____________________________________________________________________________________________


| [[BIS_fnc_initSliderValue]] |See also=
|x1= <sqf>[_lnbFilter, _lnbContent, [0,1,2,3]] call BIS_fnc_initListNBoxSorting;</sqf>
 
|seealso= [[BIS_fnc_initSliderValue]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Functions|{{uc:initListNBoxSorting}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:initListNBoxSorting}}]]

Latest revision as of 23:10, 20 November 2023

Hover & click on the images for description

Description

Description:

Automatically creates buttons and sets them up so they can be used to sort a CT_LISTNBOX. The buttons will automatically be resized to fit the column width of ctrlFilter.

By default, the ctrlContent columns are sorted by lnbText (using lnbSort). If a specific column should be sorted by lnbValue (using lnbSortByValue) instead, then something needs to be set in the data of the corresponding ctrlFilter column (literally something, the condition in the source code is (_ctrlFilter lnbData [0, _i]) != "").

Regarding ctrlFilter:

  • The position and size of this control define where the buttons for sorting are created, thus it should be placed above ctrlContent and its columns should have the same size as the columns of ctrlContent.
  • The text set in the columns is displayed as text for the buttons (the buttons are actually transparent).
  • The control can also be part of a CT_CONTROLS_GROUP. If that is the case, the buttons will be created as children of that group.
  • To keep a uniform style between vanilla and custom controls it is recommended to create a background with CT_STATIC behind ctrlFilter with colorBackground[] = { 0, 0, 0, 1 };.
See CT LISTNBOX - BIS_fnc_initListNBoxSorting Example for a full example including a config.
Execution:
call
Groups:
GUI

Syntax

Syntax:
[ctrlFilter, ctrlContent, columnIndexes, idc] call BIS_fnc_initListNBoxSorting
Parameters:
ctrlFilter: Control - dummy CT_LISTNBOX control used for setting up the filter.
ctrlContent: Control - the CT_LISTNBOX which actually contains the sortable content.
columnIndexes: Array of Numbers - (Optional, default: []) these are the column indexes of ctrlContent which should be sortable. An empty array means all columns are sortable.
idc: Number - (Optional, default: 200) used to assign IDCs to the buttons created by this function. The first button has idc, the second button has idc + 1 and so on.
Return Value:
Boolean - true on success, otherwise false

Examples

Example 1:
[_lnbFilter, _lnbContent, [0,1,2,3]] call BIS_fnc_initListNBoxSorting;

Additional Information

See also:
BIS_fnc_initSliderValue

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note