Button control: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Gamester17
No edit summary
 
(33 intermediate revisions by 14 users not shown)
Line 1: Line 1:
The button control is used for creating push buttons in XBMC. You can choose the position, size, and look of the button, as well as choosing what action(s) should be performed when pushed.
<section begin="main content" />
===Example===
The button control is used for creating push buttons in {{kodi}}. You can choose the position, size, and look of the button, as well as choosing what action(s) should be performed when pushed.
<xml>
=== Example ===
<control>
<syntaxhighlight lang="XML" enclose="div">
<control type="button" id="1">
       <description>My first button control</description>
       <description>My first button control</description>
       <type>button</type>
       <left>80</left>
      <id>1</id>
       <top>60</top>
      <posx>80</posx>
       <posy>60</posy>
       <width>250</width>
       <width>250</width>
       <height>200</height>
       <height>200</height>
       <visible>true</visible>
       <visible>true</visible>
       <colordiffuse>FFFFFFFF</colordiffuse>
       <colordiffuse>FFFFFFFF</colordiffuse>
       <texturefocus>myfocustexture.png</texturefocus>
       <texturefocus colordiffuse="FFFFAAFF">myfocustexture.png</texturefocus>
       <texturenofocus>mynormaltexture.png</texturenofocus>
       <texturenofocus colordiffuse="FFFFAAFF">mynormaltexture.png</texturenofocus>
       <label>29</label>
       <label>29</label>
      <wrapmultiline>true</wrapmultiline>
       <font>font12</font>
       <font>font12</font>
       <textcolor>FFFFFFFF</textcolor>
       <textcolor>FFFFFFFF</textcolor>
      <focusedcolor>FFFFFFFF</focusedcolor>
       <disabledcolor>80FFFFFF</disabledcolor>
       <disabledcolor>80FFFFFF</disabledcolor>
      <invalidcolor>FFFFFFFF</invalidcolor>
       <align></align>
       <align></align>
       <aligny></aligny>
       <aligny></aligny>
Line 23: Line 25:
       <textoffsety></textoffsety>
       <textoffsety></textoffsety>
       <pulseonselect></pulseonselect>
       <pulseonselect></pulseonselect>
       <onclick>XBMC.ActivateWindow(MyVideos)</onclick>
       <onclick>ActivateWindow(MyVideos)</onclick>
       <onfocus>-</onfocus>
       <onfocus></onfocus>
      <onunfocus></onunfocus>
       <onup>2</onup>
       <onup>2</onup>
       <ondown>3</ondown>
       <ondown>3</ondown>
Line 30: Line 33:
       <onright>1</onright>
       <onright>1</onright>
</control>
</control>
</xml>
</syntaxhighlight>


===Available Tags===
=== Available tags ===
Note that each tag is '''lower case only.''' This is important, as xml tags are case-sensitive.
In addition to the [[Default_control_tags]] the following tags are available. Note that each tag is '''lower case''' only. This is important, as xml tags are case-sensitive.
{| class="dtable"
{| class="prettytable"
|- class="userrow"
! Tag !! Description
| class="usercell" | '''description'''
|-
| class="usercell" | Only used to make things clear for the skinner. Not read by XBMC at all.
| '''texturefocus'''
|- class="userrow"
| Specifies the image file which should be displayed when the button has focus. [[Texture Attributes|See here for additional information about textures.]]
| class="usercell" | '''type'''
|-
| class="usercell" | Should be button for a button control.
| '''texturenofocus'''
|- class="userrow"
| Specifies the image file which should be displayed when the button does not have focus.
| class="usercell" | '''id'''
|-
| class="usercell" | Specifies the control's id. The value this takes depends on the control type, and the window that you are using the control on. There are special control id's that must be present in each window. Any other controls that the skinner adds can be any id they like. Obviously they should be unique for buttons, given that they are navigatible, and you want the onup, onleft etc. to make sense.
| '''label'''
|- class="userrow"
| The label used on the button. It can be a link into strings.po, or an actual text label.
| class="usercell" | '''posx'''
|-
| class="usercell" | Specifies where the left edge of the button should be drawn. This is offset from the window's coordinates (normally the left edge of the screen, or 0).
| '''font'''
|- class="userrow"
| Font used for the button label. From fonts.xml.
| class="usercell" | '''posy'''
|-
| class="usercell" | Specifies where the top edge of the button should be drawn. This is offset from the window's coordinates (normally the top edge of the screen, or 0).
| '''textcolor'''
|- class="userrow"
| Color used for displaying the button label. In AARRGGBB hex format, or a name from the [[Colour themes|colour theme.]]
| class="usercell" | '''width'''
|-
| class="usercell" | Specifies the width of the button. The texturefocus and texturenofocus images will be resized to fit into this width.
| '''focusedcolor'''
|- class="userrow"
| Color used for the button label when the button has in focus. In AARRGGBB hex format or a name from the [[Colour themes|colour theme.]]
| class="usercell" | '''height'''
|
| class="usercell" | Specifies the height of the button. The texturefocus and texturenofocus images will be resized to fit into this height.
| '''disabledcolor'''
|- class="userrow"
| Color used for the button label if the button is disabled. In AARRGGBB hex format or a name from the [[Colour themes|colour theme.]]
| class="usercell" | '''visible'''
|-
| class="usercell" |
| '''invalidcolor'''
Specifies a condition as to when this control will be visible. Can be true, false, or a condition. [[Conditional Visibility|See here for more information.]] Defaults to true.
| Color used for the button if the user entered some invalid value. In AARRGGBB hex format or a name from the [[Colour themes|colour theme.]]
|- class="userrow"
|
| class="usercell" | '''animation'''
| '''shadowcolor'''
| class="usercell" |
| Specifies the color of the drop shadow on the text, in AARRGGBB format, or a name from the [[Colour themes|colour theme.]]
Specifies the animation to be run when the control enters a particular state. [[Animating Your Skin|See here for more information]]
|-
|- class="userrow"
| '''angle'''
| class="usercell" | '''texturefocus'''
| The angle the text should be rendered at, in degrees. A value of 0 is horizontal.
| class="usercell" |
|-
Specifies the image file which should be displayed when the button has focus. You can use animated gif's, jpgs, pngs, or bmps. This should be the path to the image file from the media/ folder of your skin directory. XBMC will first look inside the compresses Textures.xpr file, and if not found, will look inside the media/ folder for the actual skin file. Compressing textures into Textures.xpr means far faster loading times.
| '''align'''
|- class="userrow"
| Label horizontal alignment on the button. Defaults to left, can also be center or right.
| class="usercell" | '''texturenofocus'''
|-
| class="usercell" | Specifies the image file which should be displayed when the button does not have focus.
| '''aligny'''
|- class="userrow"
| Label vertical alignment on the button. Defaults to top, can also be center.
| class="usercell" | '''colordiffuse'''
|-
| class="usercell" | This specifies the color to be used for the texture basis. It's in hex AARRGGBB format. If you define <colordiffuse>FFFF00FF</colordiffuse> (magenta), the image will be given a magenta tint when rendered. Defaults to FFFFFFFF (no tint).
| '''textoffsetx'''
|- class="userrow"
| Amount to offset the label from the left (or right) edge of the button when using left or right alignment.
| class="usercell" | '''label'''
|-
| class="usercell" | The label used on the button. It can be a link into strings.xml, or an actual text label.
| '''textoffsety'''
|- class="userrow"
| Amount to offset the label from the top edge of the button when using top alignment.
| class="usercell" | '''font'''
|-
| class="usercell" | Font used for the button label. From fonts.xml.
| '''textwidth'''
|- class="userrow"
| Will truncate any text that's too long.
| class="usercell" | '''textcolor'''
|-
| class="usercell" | Color used for displaying the button label. In AARRGGBB hex format.
| '''onclick'''
|- class="userrow"
| Specifies the action to perform when the button is pressed. Should be a built in function. [[Built-in_scripting|See here for more information.]] You may have more than one <onclick> tag, and they'll be executed in sequence.
| class="usercell" | '''disabledcolor'''
|-
| class="usercell" | Color used for the button label if the button is disabled.
| '''onfocus'''
|- class="userrow"
| Specifies the action to perform when the button is focused. Should be a built in function. The action is performed after any focus animations have completed. [[Built-in_scripting|See here for more information.]]
| class="usercell" | '''shadowcolor'''
|-
| class="usercell" | Specifies the color of the drop shadow on the text, in AARRGGBB format.
| '''onunfocus'''
|- class="userrow"
| Specifies the action to perform when the button loses focus. Should be a built in function.
| class="usercell" | '''angle'''
|-
| class="usercell" | The angle the text should be rendered at, in degrees. A value of 0 is horizontal.
| '''wrapmultiline'''
|- class="userrow"
| Will wrap the label across multiple lines if the label exceeds the control width.
| class="usercell" | '''align'''
| class="usercell" | Label horizontal alignment on the button. Defaults to left, can also be center or right.
|- class="userrow"
| class="usercell" | '''aligny'''
| class="usercell" | Label vertical alignment on the button. Defaults to top, can also be center.
|- class="userrow"
| class="usercell" | '''textoffsetx'''
| class="usercell" | Amount to offset the label from the left (or right) edge of the button when using left or right alignment.
|- class="userrow"
| class="usercell" | '''textoffsety'''
| class="usercell" | Amount to offset the label from the top edge of the button when using top alignment.
|- class="userrow"
| class="usercell" | '''pulseonselect'''
| class="usercell" | Specifies whether the button should pulse when it's selected. Defaults to true.
|- class="userrow"
| class="usercell" | '''onclick'''
| class="usercell" |
Specifies the action to perform when the button is pressed. Should be a built in function. [[Built-in functions available to FTP, Webserver, skins, keymap and to python|See here for more information.]] You may have more than one <onclick> tag, and they'll be executed in sequence.
|- class="userrow"
| class="usercell" | '''onfocus'''
| class="usercell" |
Specifies the action to perform when the button is focused. Should be a built in function. The action is performed after any focus animations have completed. [[Built-in functions available to FTP, Webserver, skins, keymap and to python|See here for more information.]]
|- class="userrow"
| class="usercell" | '''onup'''
| class="usercell" | Control id to move to when the user moves up off this control.
|- class="userrow"
| class="usercell" | '''ondown'''
| class="usercell" | Control id to move to when the user moves down off this control.
|- class="userrow"
| class="usercell" | '''onleft'''
| class="usercell" | Control id to move to when the user moves left off this control.
|- class="userrow"
| class="usercell" | '''onright'''
| class="usercell" | Control id to move to when the user moves right off this control.
|}
|}


[[category:Skin Development]]
 
[[category:Python]]
<section end="main content" />
 
== See also ==
'''Development:'''
* [[Add-on development]]
* [[Skinning]]
 
[[Category:Skin development]]

Latest revision as of 00:50, 14 April 2022

The button control is used for creating push buttons in Kodi. You can choose the position, size, and look of the button, as well as choosing what action(s) should be performed when pushed.

Example

<control type="button" id="1">
      <description>My first button control</description>
      <left>80</left>
      <top>60</top>
      <width>250</width>
      <height>200</height>
      <visible>true</visible>
      <colordiffuse>FFFFFFFF</colordiffuse>
      <texturefocus colordiffuse="FFFFAAFF">myfocustexture.png</texturefocus>
      <texturenofocus colordiffuse="FFFFAAFF">mynormaltexture.png</texturenofocus>
      <label>29</label>
      <wrapmultiline>true</wrapmultiline>
      <font>font12</font>
      <textcolor>FFFFFFFF</textcolor>
      <focusedcolor>FFFFFFFF</focusedcolor>
      <disabledcolor>80FFFFFF</disabledcolor>
      <invalidcolor>FFFFFFFF</invalidcolor>
      <align></align>
      <aligny></aligny>
      <textoffsetx></textoffsetx>
      <textoffsety></textoffsety>
      <pulseonselect></pulseonselect>
      <onclick>ActivateWindow(MyVideos)</onclick>
      <onfocus></onfocus>
      <onunfocus></onunfocus>
      <onup>2</onup>
      <ondown>3</ondown>
      <onleft>1</onleft>
      <onright>1</onright>
</control>

Available tags

In addition to the Default_control_tags the following tags are available. Note that each tag is lower case only. This is important, as xml tags are case-sensitive.

Tag Description
texturefocus Specifies the image file which should be displayed when the button has focus. See here for additional information about textures.
texturenofocus Specifies the image file which should be displayed when the button does not have focus.
label The label used on the button. It can be a link into strings.po, or an actual text label.
font Font used for the button label. From fonts.xml.
textcolor Color used for displaying the button label. In AARRGGBB hex format, or a name from the colour theme.
focusedcolor Color used for the button label when the button has in focus. In AARRGGBB hex format or a name from the colour theme.
disabledcolor Color used for the button label if the button is disabled. In AARRGGBB hex format or a name from the colour theme.
invalidcolor Color used for the button if the user entered some invalid value. In AARRGGBB hex format or a name from the colour theme.
shadowcolor Specifies the color of the drop shadow on the text, in AARRGGBB format, or a name from the colour theme.
angle The angle the text should be rendered at, in degrees. A value of 0 is horizontal.
align Label horizontal alignment on the button. Defaults to left, can also be center or right.
aligny Label vertical alignment on the button. Defaults to top, can also be center.
textoffsetx Amount to offset the label from the left (or right) edge of the button when using left or right alignment.
textoffsety Amount to offset the label from the top edge of the button when using top alignment.
textwidth Will truncate any text that's too long.
onclick Specifies the action to perform when the button is pressed. Should be a built in function. See here for more information. You may have more than one <onclick> tag, and they'll be executed in sequence.
onfocus Specifies the action to perform when the button is focused. Should be a built in function. The action is performed after any focus animations have completed. See here for more information.
onunfocus Specifies the action to perform when the button loses focus. Should be a built in function.
wrapmultiline Will wrap the label across multiple lines if the label exceeds the control width.



See also

Development: