Fix macOS implementation
This commit is contained in:
parent
23004b960f
commit
30ffa12d60
2 changed files with 7 additions and 2 deletions
|
|
@ -11,6 +11,8 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#[macro_use]
|
||||
extern crate objc;
|
||||
|
||||
use objc::runtime::{Class, Object};
|
||||
use objc_foundation::{INSArray, INSObject, INSString};
|
||||
|
|
@ -40,7 +42,7 @@ impl Clipboard {
|
|||
Ok(Clipboard { pasteboard })
|
||||
}
|
||||
|
||||
fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||
pub fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||
let string_class: Id<NSObject> = {
|
||||
let cls: Id<Class> = unsafe { Id::from_ptr(class("NSString")) };
|
||||
unsafe { transmute(cls) }
|
||||
|
|
@ -66,7 +68,7 @@ impl Clipboard {
|
|||
}
|
||||
}
|
||||
|
||||
fn write(&mut self, data: String) -> Result<(), Box<dyn Error>> {
|
||||
pub fn write(&mut self, data: String) -> Result<(), Box<dyn Error>> {
|
||||
let string_array = NSArray::from_vec(vec![NSString::from_str(&data)]);
|
||||
let _: usize = unsafe { msg_send![self.pasteboard, clearContents] };
|
||||
let success: bool =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
use crate::ClipboardProvider;
|
||||
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use std::error::Error;
|
||||
|
||||
pub fn new_clipboard<W: HasRawWindowHandle>(
|
||||
_window: &W,
|
||||
) -> Result<Box<dyn ClipboardProvider>, Box<dyn Error>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue