/// <summary> /// Handles behavior attach /// </summary> unsafe static partial void Host_HandleAttachBehavior(ISciterNotifications host, IntPtr pns) { var datantf = (SCN_ATTACH_BEHAVIOR *)pns; var e = new AttachBehaviorEventArgs(Element.Create(datantf->element), datantf->GetBehaviorName()); host.ProcessAttachBehavior(e); e.Behavior = e.Behavior ?? SciterFactory.ResolveBehavior(e.BehaviorName); if (e.Behavior != null) { datantf->elementProc = ElementEventProcEntryPoint; datantf->elementTag = InstanceProtector.Protect(e.Behavior); datantf->elementEvents = (EVENT_GROUPS)e.EventGroups; } }
/// <summary> /// Creates a scripting ctor definition from the reflection info /// </summary> private static SciterNativeMethodDef DefineCtorMethod(Type type) { return(new SciterNativeMethodDef() { name = "this", // Construction callback implementation method = (IntPtr hvm, ref JsonValue p_data_slot, IntPtr argv, int argc, ref JsonValue retval) => { try { var result = Activator.CreateInstance(type, JsonPtrToArray(argv, argc)); var data_slot_value = InstanceProtector.Protect(result); p_data_slot.SetNativeObject(data_slot_value); _registrations[hvm].Instances.Add(data_slot_value, result); } catch (Exception ex) { SciterHostApi.SciterNativeThrow(hvm, ex.Message); } } }); }
/// <summary> /// Assings host callback to the sciter window /// </summary> /// <param name="hWndSciter"></param> /// <param name="ntf"></param> public static void SciterSetCallback(IntPtr hWndSciter, ISciterNotifications ntf) { Debug.Assert(ntf != null, "Notification callback cannot be null"); HTMLayoutSetCallback(hWndSciter, _nativeCallback, InstanceProtector.Protect(ntf)); }
/// <summary> /// Attach/Detach ElementEventProc to the Sciter window. /// All events will start first here (in SINKING phase) and if not consumed will end up here. /// You can install Window EventHandler only once - it will survive all document reloads. /// </summary> public void WindowDetachEventHandler(IntPtr hWnd, ISciterBehavior bhv) { CheckResult(SciterWindowDetachEventHandler(hWnd, SciterHostApi.ElementEventProcEntryPoint, InstanceProtector.Protect(bhv))); }
/// <summary> /// Attach ElementEventProc to the element and subscribe it to events providede by subscription parameter /// See Sciter::attach_event_handler. /// </summary> public void AttachEventHandler(Element he, ISciterBehavior behavior) { CheckResult(SciterAttachEventHandler(he.Handle, SciterHostApi.ElementEventProcEntryPoint, InstanceProtector.Protect(behavior))); }
/// <summary> /// Attach/Detach ElementEventProc to the element /// See Sciter::event_handler. /// </summary> public void DetachEventHandler(Element he, ISciterBehavior behavior) { var r = SciterDetachEventHandler(he.Handle, SciterHostApi.ElementEventProcEntryPoint, InstanceProtector.Protect(behavior)); // DetachEventHandler can return SCDOM_PASSIVE_HANDLE if element was detached from the tree CheckResult(r == ScDomResult.SCDOM_PASSIVE_HANDLE ? ScDomResult.SCDOM_OK : r); }
/// <summary> /// Assings host callback to the sciter window /// </summary> /// <param name="hWndSciter"></param> /// <param name="ntf"></param> public static void SciterSetCallback(IntPtr hWndSciter, ISciterNotifications ntf) { SciterSetCallback(hWndSciter, _nativeCallback, InstanceProtector.Protect(ntf)); }