# AxSelector type

Selector  is a UI element for selecting Adaptix data.

## SelectorFile

The `selector_file` element contains a file path input field and a button to invoke a file selection dialog. If the `selector_file` is placed in a `container`, the file contents will be base64 encoded when generating the JSON.

<div align="left"><figure><img src="/files/K7sPcI1JYWAZxFQ7CV7v" alt=""><figcaption></figcaption></figure></div>

`element create_selector_file()` - Constructs a `selector_file` element contains a file path input field and a button to invoke a file selection dialog.

#### **Methods:**

{% stepper %}
{% step %}

#### setPlaceholder

```javascript
void selector_file::setPlaceholder(string text);
```

This method sets the textline placeholder text, text.
{% endstep %}
{% endstepper %}

<details>

<summary>Example</summary>

```javascript
let selector = form.create_selector_file();
let btn      = form.create_button("Dump");
let tl1      = form.create_textmulti();

let container = form.create_container();
container.put("content", selector);

form.connect(btn, "clicked", function(){
    tl1.setText(container.toJson());
});

let layout = form.create_vlayout();
layout.addWidget(selector);
layout.addWidget(tl1);
layout.addWidget(btn);

let dialog = form.create_dialog("");
dialog.setSize(400, 200);
dialog.setLayout(layout);
dialog.exec();
```

<figure><img src="/files/mbjFgUAbFJySReqBeDsw" alt=""><figcaption></figcaption></figure>

</details>

***

## SelectorAgents

The `selector_agents` is a dialog window with the Sessions table and a search field. The columns that the table should have can be specified when creating `selector_agents`.

<div align="left"><figure><img src="/files/qem8B933G4jfwHJFahx0" alt=""><figcaption></figcaption></figure></div>

`dialog create_selector_agents(string headers)` - Creates a `selector_agents` dialog with the specified `headers`. Possible columns are: *id*, *type*, *listener*, *external\_ip*, *internal\_ip*, *domain*, *computer*, *username*, *process*, *pid*, *tid*, *os*, *tags*.

#### Methods:

{% stepper %}
{% step %}

#### setSize

```javascript
void create_selector_agents::setSize(int w, int h)
```

This method sets the size for the window.
{% endstep %}

{% step %}

#### close

```javascript
void create_selector_agents::close();
```

Close window.
{% endstep %}

{% step %}

#### exec

```javascript
map(string,any)[] create_selector_agents::exec();
```

Shows the dialog as a modal dialog, blocking until the user closes it. If the window is closed by pressing the *Choose* button, the method will return an array of AGENT structures. If the window is closed otherwise, an empty array will be returned.&#x20;

```javascript
// AGENT STRUCTURE:
string agent["id"]
string agent["type"]
string agent["listener"]
string agent["external_ip"]
string agent["internal_ip"]
string agent["domain"]
string agent["computer"]
string agent["username"]
string agent["impersonated"]
string agent["process"]
string agent["pid"]
string agent["tid"]
string agent["tags"]
string agent["os"]
```

{% endstep %}
{% endstepper %}

<details>

<summary>Example</summary>

```javascript
let agents_selector = form.create_selector_agents(["id", "type", "computer", "username", "process", "pid", "tags"]);
agents_selector.setSize(1000, 400);

let agent_label    = form.create_label("Agent:");
let agent_text     = form.create_textline();
let select_button  = form.create_button("...");
let computer_label = form.create_label("Computer:");
let computer_text  = form.create_textline();
let username_label = form.create_label("Username:");
let username_text  = form.create_textline();

form.connect(select_button, "clicked", function(){
    let agents = agents_selector.exec();
    if (agents.length > 0) {
        let agent = agents[0];
        agent_text.setText(agent["id"]);
        computer_text.setText(agent["computer"]);
        username_text.setText(agent["username"]);
    }
});

let layout = form.create_gridlayout();
layout.addWidget(agent_label,    0, 0, 1, 1);
layout.addWidget(agent_text,     0, 1, 1, 1);
layout.addWidget(select_button,  0, 2, 1, 1);
layout.addWidget(computer_label, 1, 0, 1, 1);
layout.addWidget(computer_text,  1, 1, 1, 1);
layout.addWidget(username_label, 2, 0, 1, 1);
layout.addWidget(username_text,  2, 1, 1, 1);

let dialog = form.create_dialog("Agents info");
dialog.setSize(400, 300);
dialog.setLayout(layout);
dialog.exec();
```

<figure><img src="/files/ulcEklpqenqKb568g6Mm" alt=""><figcaption></figcaption></figure>

</details>

***

## SelectorCredentials

The `selector_credentials` is a dialog window with the *Credentials Manager* table and a search field. The columns that the table should have can be specified when creating `selector_credentials`.

<div align="left"><figure><img src="/files/MWDZp5SSEKtQ4PT8LX1Y" alt=""><figcaption></figcaption></figure></div>

`dialog create_selector_credentials(string headers)` - Creates a `selector_credentials` dialog with the specified `headers`. Possible columns are: *username*, *password*, *realm*, *type*, *tag*, *date*, *storage*, *agent\_id*, *host*.

#### Methods:

{% stepper %}
{% step %}

#### setSize

```javascript
void create_selector_credentials::setSize(int w, int h)
```

This method sets the size for the window.
{% endstep %}

{% step %}

#### close

```javascript
void create_selector_credentials::close();
```

Close window.
{% endstep %}

{% step %}

#### exec

```javascript
map(string,any)[] create_selector_credentials::exec();
```

Shows the dialog as a modal dialog, blocking until the user closes it. If the window is closed by pressing the *Choose* button, the method will return an array of CRED structures. If the window is closed otherwise, an empty array will be returned.&#x20;

```javascript
// CRED STRUCTURE:
string cred["username"]
string cred["password"]
string cred["realm"]
string cred["type"]
string cred["tag"]
string cred["date"]
string cred["storage"]
string cred["agent_id"]
string cred["host"]
string cred["id"]
```

{% endstep %}
{% endstepper %}

<details>

<summary>Example</summary>

```javascript
let creds_selector = form.create_selector_credentials(["username", "password", "realm", "tag"]);
creds_selector.setSize(800, 400);

let username_label = form.create_label("Username:");
let username_text  = form.create_textline();
let select_button  = form.create_button("...");
let password_label = form.create_label("Password:");
let password_text  = form.create_textline();
let realm_label    = form.create_label("Realm:");
let realm_text     = form.create_textline();

form.connect(select_button, "clicked", function(){
    let cred_list = creds_selector.exec();
    if (cred_list.length > 0) {
        let cred = cred_list[0];
        username_text.setText(cred["username"]);
        password_text.setText(cred["password"]);
        realm_text.setText(cred["realm"]);
    }
});

let layout = form.create_gridlayout();
layout.addWidget(username_label, 0, 0, 1, 1);
layout.addWidget(username_text,  0, 1, 1, 1);
layout.addWidget(select_button,  0, 2, 1, 1);
layout.addWidget(password_label, 1, 0, 1, 1);
layout.addWidget(password_text,  1, 1, 1, 1);
layout.addWidget(realm_label,    2, 0, 1, 1);
layout.addWidget(realm_text,     2, 1, 1, 1);

let dialog = form.create_dialog("");
dialog.setSize(400, 300);
dialog.setLayout(layout);
dialog.exec();
```

<figure><img src="/files/JFdrZru28lgvlGJpG0WJ" alt=""><figcaption></figcaption></figure>

</details>

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://adaptix-framework.gitbook.io/adaptix-framework/development/axscript/axselector-type.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
