<?xml version="1.0" encoding="UTF-8"?>
<panel title="searchbox" height="30">

  <!-- active area -->
  <container>
    <layout class="arrange_horizontal_attachment" alignment="fill" offset="0" gap="0" layout="-1, 200, 350"/>
    <layout class="stick_to_sides_attachment" alignment="vertical" inset="0" layout_children="true" />
    <layout class="stick_to_sides_attachment" alignment="all" inset="2" />

    <container></container>

    <container id="msbo">
      <layout class="centre_in_parent_attachment" alignment="all" inset="0" layout_children="true" priority="1" />
      <layout class="fit_children_attachment" alignment="all" offset="0"/>

      <widget id="find" class="edit_box" appearance="interface/searchbox/box" width="200" colour="continue button text">
        <attachment kind="max_length_attachment" length="180" />

        <!-- sent the return/enter key event to the screen: it causes a quick search to be performed -->
        <event id="return_event">
          <flags id="event_id" value="DBSR"/>
          <flags id="event_target" value="scrn"/>
        </event>

        <!-- sent the edit event to the screen: will store the search text to set in the next screen (could be the match title bar) -->
        <event id="edit_event">
          <flags id="event_id" value="DBSC"/>
          <flags id="event_target" value="scrn"/>
        </event>

        <!-- send the text changed event to the clear button: if the text is empty, the clear button is disabled or removed -->
        <event id="changed_event">
          <flags id="event_id" value="chtx" />
          <flags id="event_target" value="finb" />
        </event>

        <!-- check the global property that specifies if the game is set up or loaded (ie if we can do a quick search) -->
        <attachment class="test_global_attachment" get_property="gset" value="false" set_property="disa"/>
        <attachment class="get_global_attachment" get_property="qset" set_property="text"/>
      </widget>

      <!-- search button -->
      <widget class="action_button" id="srch" text="" appearance="icons/quick links/search/button" auto_size="all" >
        <layout class="stick_to_sides_attachment" alignment="left" inset="6"/>
        <!--for the click event, we send a return to the edit box-->
        <event id="click_event">
          <flags id="event_id" value="keyp"/>
          <flags id="event_target" value="find"/>
          <!--5 is KEY_RETURN - see keyboard_flags.h-->
          <flags id="code" value="5"/>
        </event>

        <!-- check for the 'gset' property, which indicates if the game is loaded or set up -->
        <attachment class="test_global_attachment" get_property="gset" value="false" set_property="disa"/>

      </widget>

      <!-- Button to clear the contents of the searchbox -->
      <widget class="action_button" id="finb" auto_size="all" appearance="interface/searchbox/clear/button" hidden="true">
        <layout class="stick_to_sides_attachment" alignment="right" inset="6"/>

        <!-- click event sends the deletion/clear event to the find edit box -->
        <event id="click_event">
          <flags id="event_id" value="DELE"/>
          <flags id="event_target" value="find"/>
        </event>

        <!-- check for the 'gset' property, which indicates if the game is loaded or set up -->
        <attachment class="test_global_attachment" get_property="gset" value="false" set_property="disa"/>

        <!-- check for the change text (chtx) event that edit box will send us when: we check the 'text is empty' property of the event and set the disabled property to the value of 'chtx' -->
        <attachment class="test_event_attachment" event_id="chtx" get_property="txie" set_property="hidn" mode="1" />
      </widget>
    </container>

    <container></container>

  </container>

</panel>
