Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/avm2/globals/flash/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

pub mod application_domain;
pub mod security;
pub mod system;
2 changes: 2 additions & 0 deletions core/src/avm2/globals/flash/system/System.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ package flash.system {
public static function gc(): void {

}

public static native function setClipboard(string:String): void;
}
}
25 changes: 25 additions & 0 deletions core/src/avm2/globals/flash/system/system.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! `flash.system.System` native methods

use crate::avm2::activation::Activation;
use crate::avm2::object::Object;
use crate::avm2::value::Value;
use crate::avm2::Error;

/// Implements `flash.system.System.setClipboard` method
pub fn set_clipboard<'gc>(
activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
//TODO: in FP9+ this function only works when called from a button handler in the Plugin due to
// sandbox restrictions
let new_content = args
.get(0)
.unwrap_or(&Value::Undefined)
.coerce_to_string(activation)?
.to_string();

activation.context.ui.set_clipboard_content(new_content);

Ok(Value::Undefined)
}
2 changes: 2 additions & 0 deletions web/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ impl UiBackend for WebUiBackend {
}

fn set_clipboard_content(&mut self, _content: String) {
//TODO: in AVM2 FP9+ this only works when called from a button handler due to sandbox
// restrictions
log::warn!("set clipboard not implemented");
}

Expand Down