Skip to main content

EventCtx

Struct EventCtx 

Source
pub struct EventCtx<'a> {
    pub ui: &'a mut Ui,
    pub id: ComponentId,
    /* private fields */
}
Expand description

Contexto entregue aos métodos de evento de um componente.

Enquanto o método roda, o componente está “fora” do Ui (por isso ui.get(ctx.id) devolve None ali dentro). Os eventos disparados com fire são entregues aos handlers depois que o método termina, quando o componente já voltou — assim um handler pode alterar o próprio componente que disparou o evento.

Fields§

§ui: &'a mut Ui§id: ComponentId

Implementations§

Source§

impl<'a> EventCtx<'a>

Source

pub fn new(ui: &'a mut Ui, id: ComponentId) -> Self

Source

pub fn fire(&mut self, event: &str, args: EventArgs)

Agenda o evento event (por exemplo "on_click") deste componente.

Source

pub fn repaint(&mut self)

Pede uma nova pintura. Chame quando o método mudar algo visual do próprio componente (alterações feitas por ctx.ui já pedem sozinhas). Só a área dele é repintada (Ui::damage); se o desenho mudou fora dela, use ctx.ui.request_repaint().

Source

pub fn repaint_part(&mut self, rect: RectF)

Só a parte rect do componente mudou (nas coordenadas dele): a barra de rolagem, o cursor. Veja Ui::damage_part.

Source

pub fn scrolled(&mut self, rect: RectF, delta: PointF)

O conteúdo de rect (nas coordenadas do componente) andou delta (a rolagem): a plataforma copia os pixels já pintados e só a faixa que apareceu é pintada. Veja Ui::scroll_damage.

Source

pub fn invalidate(&mut self)

Pede novo layout e nova pintura (quando o método mudou tamanho, posição, alinhamento… do próprio componente).

Source

pub fn request_focus(&mut self, id: ComponentId)

Muda o foco para id assim que este método terminar. Use dentro de métodos de evento: enquanto o método roda, o próprio componente está fora do Ui e não pode ganhar nem perder o foco na hora.

Source

pub fn set_handled(&mut self)

Marca o evento como tratado (não propaga para o pai).

Source

pub fn handled(&self) -> bool

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for EventCtx<'a>

§

impl<'a> !Send for EventCtx<'a>

§

impl<'a> !Sync for EventCtx<'a>

§

impl<'a> !UnwindSafe for EventCtx<'a>

§

impl<'a> Forget for EventCtx<'a>

§

impl<'a> Freeze for EventCtx<'a>

§

impl<'a> Move for EventCtx<'a>

§

impl<'a> Unpin for EventCtx<'a>

§

impl<'a> UnsafeUnpin for EventCtx<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.