pub struct Element { /* private fields */ }
Expand description
DOM element wrapper. See the module-level documentation also.
Implementations
sourceimpl Element
impl Element
sourcepub fn create(tag: &str) -> Result<Element>
pub fn create(tag: &str) -> Result<Element>
Create a new element, it is disconnected initially from the DOM.
sourcepub fn with_parent(tag: &str, parent: &mut Element) -> Result<Element>
pub fn with_parent(tag: &str, parent: &mut Element) -> Result<Element>
Create new element as child of parent
.
sourcepub fn create_at(tag: &str, parent: &mut Element) -> Result<Element>
👎 Deprecated since 0.5.0: please use Element::with_parent()
instead.
pub fn create_at(tag: &str, parent: &mut Element) -> Result<Element>
please use Element::with_parent()
instead.
Create new element as child of parent
. Deprecated.
sourcepub fn with_text(tag: &str, text: &str) -> Result<Element>
pub fn with_text(tag: &str, text: &str) -> Result<Element>
Create new element with specified text
, it is disconnected initially from the DOM.
sourcepub fn with_type(tag: &str, el_type: &str) -> Result<Element>
pub fn with_type(tag: &str, el_type: &str) -> Result<Element>
Create new element with specified type
, which is useful for controls and widgets (initially disconnected).
sourcepub fn from_window(hwnd: HWINDOW) -> Result<Element>
pub fn from_window(hwnd: HWINDOW) -> Result<Element>
Get the root DOM element of the Sciter document.
If there is no document loaded, this function will return an error.
sourcepub fn from_focus(hwnd: HWINDOW) -> Result<Element>
pub fn from_focus(hwnd: HWINDOW) -> Result<Element>
Get focus DOM element of the Sciter document.
If there is no such element, this function will return an error.
sourcepub fn from_highlighted(hwnd: HWINDOW) -> Result<Element>
pub fn from_highlighted(hwnd: HWINDOW) -> Result<Element>
Get highlighted element.
If there is no such element, this function will return an error.
sourcepub fn from_point(hwnd: HWINDOW, pt: POINT) -> Result<Element>
pub fn from_point(hwnd: HWINDOW, pt: POINT) -> Result<Element>
Find DOM element of the Sciter document by coordinates.
If there is no such element, this function will return an error.
sourcepub fn from_uid(hwnd: HWINDOW, uid: u32) -> Result<Element>
pub fn from_uid(hwnd: HWINDOW, uid: u32) -> Result<Element>
Get element handle by its UID.
If there is no such element, this function will return an error.
sourcepub fn get_html(&self, with_outer_html: bool) -> Vec<u8>
pub fn get_html(&self, with_outer_html: bool) -> Vec<u8>
Get html representation of the element as utf-8 bytes.
sourcepub fn set_html(
&mut self,
html: &[u8],
how: Option<SET_ELEMENT_HTML>
) -> Result<()>
pub fn set_html(
&mut self,
html: &[u8],
how: Option<SET_ELEMENT_HTML>
) -> Result<()>
Set inner or outer html of the element.
sourcepub fn get_state(&self) -> ELEMENT_STATE_BITS
pub fn get_state(&self) -> ELEMENT_STATE_BITS
Checks if particular UI state bits are set in the element.
sourcepub fn set_state(
&mut self,
set: ELEMENT_STATE_BITS,
clear: Option<ELEMENT_STATE_BITS>,
update: bool
) -> Result<()>
pub fn set_state(
&mut self,
set: ELEMENT_STATE_BITS,
clear: Option<ELEMENT_STATE_BITS>,
update: bool
) -> Result<()>
Set UI state of the element with optional view update.
sourcepub fn attach_hwnd(&mut self, child: HWINDOW) -> Result<()>
pub fn attach_hwnd(&mut self, child: HWINDOW) -> Result<()>
Attach a native window to the element as a child.
sourcepub fn detach_hwnd(&mut self) -> Result<()>
pub fn detach_hwnd(&mut self) -> Result<()>
Detach a child native window (if any) from the element.
sourcepub fn get_location(&self, kind: u32) -> Result<RECT>
pub fn get_location(&self, kind: u32) -> Result<RECT>
Get bounding rectangle of the element. See the ELEMENT_AREAS
enum for kind
flags.
sourcepub fn request_data(
&self,
url: &str,
data_type: RESOURCE_TYPE,
initiator: Option<HELEMENT>
) -> Result<()>
pub fn request_data(
&self,
url: &str,
data_type: RESOURCE_TYPE,
initiator: Option<HELEMENT>
) -> Result<()>
Request data download for this element.
sourcepub fn request_html(&self, url: &str, initiator: Option<HELEMENT>) -> Result<()>
pub fn request_html(&self, url: &str, initiator: Option<HELEMENT>) -> Result<()>
Request HTML data download for this element.
sourcepub fn send_get_request(&self, url: &str) -> Result<()>
pub fn send_get_request(&self, url: &str) -> Result<()>
Send an asynchronous HTTP GET request for the element.
The contents of this element is replaced with the HTTP response (in text or html form).
sourcepub fn send_request(
&self,
url: &str,
params: Option<&[(&str, &str)]>,
method: Option<REQUEST_TYPE>,
data_type: Option<RESOURCE_TYPE>
) -> Result<()>
pub fn send_request(
&self,
url: &str,
params: Option<&[(&str, &str)]>,
method: Option<REQUEST_TYPE>,
data_type: Option<RESOURCE_TYPE>
) -> Result<()>
Send an HTTP GET or POST request for the element.
GET params (if any) are appended to the url to form the request.
HTTP POST params are serialized as Content-Type: application/x-www-form-urlencoded;charset=utf-8;
.
sourcepub fn send_event(
&self,
code: BEHAVIOR_EVENTS,
reason: Option<CLICK_REASON>,
source: Option<HELEMENT>
) -> Result<bool>
pub fn send_event(
&self,
code: BEHAVIOR_EVENTS,
reason: Option<CLICK_REASON>,
source: Option<HELEMENT>
) -> Result<bool>
Sends sinking/bubbling event to the child/parent chain of the element.
sourcepub fn post_event(
&self,
code: BEHAVIOR_EVENTS,
reason: Option<CLICK_REASON>,
source: Option<HELEMENT>
) -> Result<()>
pub fn post_event(
&self,
code: BEHAVIOR_EVENTS,
reason: Option<CLICK_REASON>,
source: Option<HELEMENT>
) -> Result<()>
Post asynchronously a sinking/bubbling event to the child/parent chain of the element.
sourcepub fn fire_event(
&self,
code: BEHAVIOR_EVENTS,
reason: Option<CLICK_REASON>,
source: Option<HELEMENT>,
post: bool,
data: Option<Value>
) -> Result<bool>
pub fn fire_event(
&self,
code: BEHAVIOR_EVENTS,
reason: Option<CLICK_REASON>,
source: Option<HELEMENT>,
post: bool,
data: Option<Value>
) -> Result<bool>
Send or posts event to the child/parent chain of the element.
sourcepub fn fire_event_params(
evt: &BEHAVIOR_EVENT_PARAMS,
post: bool
) -> Result<bool>
pub fn fire_event_params(
evt: &BEHAVIOR_EVENT_PARAMS,
post: bool
) -> Result<bool>
Send or posts event with specified params to the child/parent chain of the element.
sourcepub fn broadcast_event(
&self,
name: &str,
post: bool,
data: Option<Value>
) -> Result<bool>
pub fn broadcast_event(
&self,
name: &str,
post: bool,
data: Option<Value>
) -> Result<bool>
Broadcast a custom named event to all windows.
sourcepub fn eval_script(&self, script: &str) -> Result<Value>
pub fn eval_script(&self, script: &str) -> Result<Value>
Evaluate the given script in context of the element.
sourcepub fn call_function(&self, name: &str, args: &[Value]) -> Result<Value>
pub fn call_function(&self, name: &str, args: &[Value]) -> Result<Value>
Call scripting function defined in the namespace of the element (a.k.a. global function).
You can use the make_args!(args...)
macro which helps you
to construct script arguments from Rust types.
sourcepub fn call_method(&self, name: &str, args: &[Value]) -> Result<Value>
pub fn call_method(&self, name: &str, args: &[Value]) -> Result<Value>
Call scripting method defined for the element.
You can use the make_args!(args...)
macro which helps you
to construct script arguments from Rust types.
sourcepub fn call_behavior_method(&self, params: MethodParams<'_>) -> Result<()>
pub fn call_behavior_method(&self, params: MethodParams<'_>) -> Result<()>
Call behavior specific method.
sourcepub fn attribute_count(&self) -> usize
pub fn attribute_count(&self) -> usize
Get number of the attributes.
sourcepub fn attribute_name(&self, index: usize) -> String
pub fn attribute_name(&self, index: usize) -> String
Get attribute name by its index.
sourcepub fn get_attribute(&self, name: &str) -> Option<String>
pub fn get_attribute(&self, name: &str) -> Option<String>
Get attribute value by its name.
sourcepub fn set_attribute(&mut self, name: &str, value: &str) -> Result<()>
pub fn set_attribute(&mut self, name: &str, value: &str) -> Result<()>
Add or replace attribute.
sourcepub fn remove_attribute(&mut self, name: &str) -> Result<()>
pub fn remove_attribute(&mut self, name: &str) -> Result<()>
Remove attribute.
sourcepub fn toggle_attribute(
&mut self,
name: &str,
isset: bool,
value: Option<&str>
) -> Result<()>
pub fn toggle_attribute(
&mut self,
name: &str,
isset: bool,
value: Option<&str>
) -> Result<()>
Toggle attribute.
sourcepub fn clear_attributes(&mut self) -> Result<()>
pub fn clear_attributes(&mut self) -> Result<()>
Remove all attributes from the element.
sourcepub fn get_style_attribute(&self, name: &str) -> String
pub fn get_style_attribute(&self, name: &str) -> String
Get style attribute of the element by its name.
sourcepub fn set_style_attribute(&mut self, name: &str, value: &str) -> Result<()>
pub fn set_style_attribute(&mut self, name: &str, value: &str) -> Result<()>
Set style attribute.
sourcepub fn first_sibling(&self) -> Option<Element>
pub fn first_sibling(&self) -> Option<Element>
Get first sibling element.
sourcepub fn last_sibling(&self) -> Option<Element>
pub fn last_sibling(&self) -> Option<Element>
Get last sibling element.
sourcepub fn next_sibling(&self) -> Option<Element>
pub fn next_sibling(&self) -> Option<Element>
Get next sibling element.
sourcepub fn prev_sibling(&self) -> Option<Element>
pub fn prev_sibling(&self) -> Option<Element>
Get previous sibling element.
sourcepub fn first_child(&self) -> Option<Element>
pub fn first_child(&self) -> Option<Element>
Get first child element.
sourcepub fn last_child(&self) -> Option<Element>
pub fn last_child(&self) -> Option<Element>
Get last child element.
sourcepub fn children(&self) -> Children<'_>ⓘNotable traits for Children<'a>impl<'a> Iterator for Children<'a> type Item = Element;
pub fn children(&self) -> Children<'_>ⓘNotable traits for Children<'a>impl<'a> Iterator for Children<'a> type Item = Element;
An iterator over the direct children of a DOM element.
sourcepub fn children_count(&self) -> usize
pub fn children_count(&self) -> usize
Get number of child elements.
sourcepub fn clone_element(&self) -> Element
pub fn clone_element(&self) -> Element
Create new element as copy of existing element.
The new element is a full (deep) copy of the element and is initially disconnected from the DOM.
Note that Element.clone()
does not clone the DOM element,
just increments its reference count.
sourcepub fn insert(&mut self, index: usize, child: &Element) -> Result<()>
pub fn insert(&mut self, index: usize, child: &Element) -> Result<()>
Insert element at index
position of this element.
Note that we cannot follow Rust semantic here
because the newly created Element
is unusable before it will be inserted at DOM.
sourcepub fn append(&mut self, child: &Element) -> Result<()>
pub fn append(&mut self, child: &Element) -> Result<()>
Append element as last child of this element.
sourcepub fn pop(&mut self) -> Option<Element>
pub fn pop(&mut self) -> Option<Element>
Remove the last child from this element and returns it, or None
if this element is empty.
sourcepub fn destroy(&mut self) -> Result<()>
pub fn destroy(&mut self) -> Result<()>
Take element out of its container (and DOM tree) and force destruction of all behaviors.
sourcepub fn find_nearest_parent(&self, selector: &str) -> Result<Option<Element>>
pub fn find_nearest_parent(&self, selector: &str) -> Result<Option<Element>>
Will find first parent element starting from this satisfying given css selector(s).
sourcepub fn find_first(&self, selector: &str) -> Result<Option<Element>>
pub fn find_first(&self, selector: &str) -> Result<Option<Element>>
Will find first element starting from this satisfying given css selector(s).
sourcepub fn find_all(&self, selector: &str) -> Result<Option<Vec<Element>>>
pub fn find_all(&self, selector: &str) -> Result<Option<Vec<Element>>>
Will find all elements starting from this satisfying given css selector(s).
sourcepub fn update(&self, render_now: bool) -> Result<()>
pub fn update(&self, render_now: bool) -> Result<()>
Apply changes and refresh element area in its window.
sourcepub fn refresh(&self) -> Result<()>
pub fn refresh(&self) -> Result<()>
Refresh element area in its window.
If the element has drawing behavior attached it will receive on_draw
call after that.
sourcepub fn start_timer(&self, period_ms: u32, timer_id: u64) -> Result<()>
pub fn start_timer(&self, period_ms: u32, timer_id: u64) -> Result<()>
Start Timer for the element.
Element will receive on_timer
events.
Note that timer events are not bubbling, so you need attach handler to the target element directly.
sourcepub fn stop_timer(&self, timer_id: u64) -> Result<()>
pub fn stop_timer(&self, timer_id: u64) -> Result<()>
Stop Timer for the element.
sourcepub fn attach_handler<Handler: EventHandler>(
&mut self,
handler: Handler
) -> Result<u64>
pub fn attach_handler<Handler: EventHandler>(
&mut self,
handler: Handler
) -> Result<u64>
Attach the native event handler to this element.
sourcepub fn detach_handler<Handler: EventHandler>(
&mut self,
token: u64
) -> Result<()>
pub fn detach_handler<Handler: EventHandler>(
&mut self,
token: u64
) -> Result<()>
Detach your handler from the element. Handlers identified by token
from attach_handler()
result.
Trait Implementations
sourceimpl FromValue for Element
impl FromValue for Element
Get an Element
object contained in the Value
.
sourcefn from_value(v: &Value) -> Option<Element>
fn from_value(v: &Value) -> Option<Element>
Converts value to specified type.
impl Send for Element
sciter::Element
can be transferred across thread boundaries.
impl StructuralPartialEq for Element
impl Sync for Element
It is safe to share sciter::Element
between threads - underlaying API is thread-safe.
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more