Accepts first mouse (#2457)
* MacOS: set value for `accepts_first_mouse` * Update CHANGELOG and FEATURES * Field doesn't need to be public * Convert `bool` to `BOOL` * Fix formatting * Move flag from window state to view instance * Feedback from PR * Fix changelog location
This commit is contained in:
parent
58f2455aa9
commit
48b843e42d
5 changed files with 30 additions and 6 deletions
|
|
@ -136,6 +136,7 @@ declare_class!(
|
|||
_ns_window: IvarDrop<Id<WinitWindow, Shared>>,
|
||||
pub(super) state: IvarDrop<Box<ViewState>>,
|
||||
marked_text: IvarDrop<Id<NSMutableAttributedString, Owned>>,
|
||||
accepts_first_mouse: bool,
|
||||
}
|
||||
|
||||
unsafe impl ClassType for WinitView {
|
||||
|
|
@ -144,8 +145,12 @@ declare_class!(
|
|||
}
|
||||
|
||||
unsafe impl WinitView {
|
||||
#[sel(initWithId:)]
|
||||
fn init_with_id(&mut self, window: *mut WinitWindow) -> Option<&mut Self> {
|
||||
#[sel(initWithId:acceptsFirstMouse:)]
|
||||
fn init_with_id(
|
||||
&mut self,
|
||||
window: *mut WinitWindow,
|
||||
accepts_first_mouse: bool,
|
||||
) -> Option<&mut Self> {
|
||||
let this: Option<&mut Self> = unsafe { msg_send![super(self), init] };
|
||||
this.map(|this| {
|
||||
let state = ViewState {
|
||||
|
|
@ -165,6 +170,7 @@ declare_class!(
|
|||
);
|
||||
Ivar::write(&mut this.state, Box::new(state));
|
||||
Ivar::write(&mut this.marked_text, NSMutableAttributedString::new());
|
||||
Ivar::write(&mut this.accepts_first_mouse, accepts_first_mouse);
|
||||
|
||||
this.setPostsFrameChangedNotifications(true);
|
||||
|
||||
|
|
@ -911,14 +917,20 @@ declare_class!(
|
|||
#[sel(acceptsFirstMouse:)]
|
||||
fn accepts_first_mouse(&self, _event: &NSEvent) -> bool {
|
||||
trace_scope!("acceptsFirstMouse:");
|
||||
true
|
||||
*self.accepts_first_mouse
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
impl WinitView {
|
||||
pub(super) fn new(window: &WinitWindow) -> Id<Self, Shared> {
|
||||
unsafe { msg_send_id![msg_send_id![Self::class(), alloc], initWithId: window] }
|
||||
pub(super) fn new(window: &WinitWindow, accepts_first_mouse: bool) -> Id<Self, Shared> {
|
||||
unsafe {
|
||||
msg_send_id![
|
||||
msg_send_id![Self::class(), alloc],
|
||||
initWithId: window,
|
||||
acceptsFirstMouse: accepts_first_mouse,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
fn window(&self) -> Id<WinitWindow, Shared> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue