polyhorn_ios_sys/polykit/
text_input_view.rs1use objc::runtime::*;
2use objc::*;
3
4use super::PLYView;
5use crate::foundation::NSAttributedString;
6use crate::Raw;
7
8pub struct PLYTextInputView {
10 pub(super) object: *mut Object,
11}
12
13impl PLYTextInputView {
14 pub fn new() -> PLYTextInputView {
16 unsafe {
17 let mut object: *mut Object = msg_send![class!(PLYTextInputView), alloc];
18 object = msg_send![object, init];
19 PLYTextInputView { object }
20 }
21 }
22
23 pub fn set_attributed_placeholder(&mut self, placeholder: &NSAttributedString) {
26 unsafe {
27 let _: () = msg_send![self.object, setAttributedPlaceholder: placeholder.as_raw()];
28 }
29 }
30
31 pub fn to_view(&self) -> PLYView {
33 unsafe { PLYView::from_raw_retain(self.object) }
34 }
35}
36
37impl Raw for PLYTextInputView {
38 unsafe fn from_raw(object: *mut Object) -> Self {
39 PLYTextInputView { object }
40 }
41
42 unsafe fn as_raw(&self) -> *mut Object {
43 self.object
44 }
45}
46
47impl Clone for PLYTextInputView {
48 fn clone(&self) -> Self {
49 unsafe { Self::from_raw_retain(self.as_raw()) }
50 }
51}
52
53impl Drop for PLYTextInputView {
54 fn drop(&mut self) {
55 unsafe { objc_release(self.object) }
56 }
57}