Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
2114: Re-export the TargetedEvent trait r=jojolepro a=bonsairobo

## Description

Re-export the TargetedEvent trait. I found this useful as a trait bound in my project. Might as well standardize it.

## Additions

- A couple doc comments explaining the trait.

## Modifications

- One new trait export from amethyst_ui

## PR Checklist

By placing an x in the boxes I certify that I have:

- [ ] Updated the content of the book if this PR would make the book outdated.
- [ ] Added a changelog entry if this will impact users, or modified more than 5 lines of Rust that wasn't a doc comment.
- [ ] Added unit tests for new code added in this PR.
- [x] Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme.

If this modified or created any rs files:

- [x] Ran `cargo +stable fmt --all`
- [x] Ran `cargo clippy --all --features "empty"`
- [x] Ran `cargo test --all --features "empty"`


Co-authored-by: Duncan <[email protected]>
  • Loading branch information
bors[bot] and bonsairobo authored Jan 31, 2020
2 parents 07db6e4 + 7c0ddbb commit a34ede1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions amethyst_ui/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use serde::{Deserialize, Serialize};
use std::marker::PhantomData;
use winit::MouseButton;

/// An event that pertains to a specific `Entity`, for example a `UiEvent` for clicking on a widget
/// entity.
pub trait TargetedEvent {
/// The `Entity` targeted by the event.
fn get_target(&self) -> Entity;
}

Expand Down
4 changes: 3 additions & 1 deletion amethyst_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ pub use self::{
UiButtonBuilderResources, UiButtonSystem, UiButtonSystemDesc,
},
drag::{DragWidgetSystemDesc, Draggable},
event::{targeted, targeted_below, Interactable, UiEvent, UiEventType, UiMouseSystem},
event::{
targeted, targeted_below, Interactable, TargetedEvent, UiEvent, UiEventType, UiMouseSystem,
},
event_retrigger::{
EventReceiver, EventRetrigger, EventRetriggerSystem, EventRetriggerSystemDesc,
},
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog][kc], and this project adheres to

### Changed

- Re-export `TargetedEvent` from amethyst_ui. ([#2114])

### Deprecated

### Removed
Expand All @@ -23,6 +25,8 @@ The format is based on [Keep a Changelog][kc], and this project adheres to

### Security

[#2114]: https://github.com/amethyst/amethyst/pull/2114

## [0.14.0] - 2020-01-30

### Added
Expand Down

0 comments on commit a34ede1

Please sign in to comment.