Skip to content

Commit 4bcf50a

Browse files
committed
+ Added SciterAPIHost.ElementFromValue and SciterAPIHost.ElementToValue
1 parent b5f5336 commit 4bcf50a

4 files changed

Lines changed: 36 additions & 6 deletions

File tree

EmptyFlow.SciterAPI/Client/HostValueAPI.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,39 @@ public SciterValue ValueInvoke ( ref SciterValue value, SciterValue? context, IE
211211
m_basicApi.ValueInit ( out sciterValue );
212212
functionContext = sciterValue;
213213
}
214-
m_basicApi.ValueInvoke ( ref value, ref functionContext, (uint) parameters.Count (), parameters.ToArray(), out var result, IntPtr.Zero );
214+
m_basicApi.ValueInvoke ( ref value, ref functionContext, (uint) parameters.Count (), parameters.ToArray (), out var result, IntPtr.Zero );
215215

216216
return result;
217217
}
218218

219+
/// <summary>
220+
/// Fetch DOM element reference from SCITER_VALUE envelope.
221+
/// </summary>
222+
/// <returns>Return element.</returns>
223+
/// <exception cref="Exception">If Result will be not zero it will be part of error message.</exception>
224+
public nint ElementFromValue ( SciterValue sciterValue ) {
225+
var pointer = nint.Zero;
226+
var domResult = m_basicApi.SciterElementUnwrap ( sciterValue, ref pointer );
227+
if ( domResult != 0 ) throw new Exception ( $"Can't get element from value. DomResult is {domResult}" );
228+
229+
return pointer;
230+
}
231+
232+
/// <summary>
233+
/// Wrap DOM element reference into sciter::value envelope.
234+
/// </summary>
235+
/// <returns>Value.</returns>
236+
/// <exception cref="Exception">If Result will be not zero it will be part of error message.</exception>
237+
public SciterValue ElementToValue (nint element) {
238+
SciterValue sciterValue;
239+
m_basicApi.ValueInit ( out sciterValue );
240+
241+
var domResult = m_basicApi.SciterElementWrap ( ref sciterValue, element );
242+
if ( domResult != 0 ) throw new Exception ( $"Can't wrap value to element. DomResult is {domResult}" );
243+
244+
return sciterValue;
245+
}
246+
219247
}
220248

221249
}

EmptyFlow.SciterAPI/EmptyFlow.SciterAPI.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
<RepositoryUrl>https://github.com/EmptyFlow/SciterAPI</RepositoryUrl>
1717
<RepositoryType>git</RepositoryType>
1818
<PackageTags>html;html-engine;htmlengine;sciter;binding</PackageTags>
19-
<Version>1.0.2.0</Version>
19+
<Version>1.0.3.0</Version>
2020
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2121
<PackageReleaseNotes>
2222
Added SciterAPIHost.LoadHtml for load HTML page as string
2323
Added SciterAPIHost.GetElementChildrensCount for get count of childrens for specified element
2424
Added SciterAPIHost.ClearAttributes for clear all element attributes
2525
Added SciterAPIHost.ElementFromValue for get element from value
2626
Added SciterAPIHost.ElementToValue wrap element reference into value
27-
Added SciterAPIHost.SetSharedVariable for set global variable in all or one window
27+
Added SciterAPIHost.SetSharedVariable for set global variable in all or one window
28+
Added SciterAPIHost.SetMainWindowVariable for set global variable in main window
29+
Added SciterAPIHost.GetMainWindowVariable for get global variable for main window
2830
</PackageReleaseNotes>
2931
</PropertyGroup>
3032

EmptyFlow.SciterAPI/Structs/SciterApiStruct.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ namespace EmptyFlow.SciterAPI.Structs {
198198

199199
public delegate uint SciterSetVariable ( IntPtr hwndOrNull, [MarshalAs ( UnmanagedType.LPStr )] string name, SciterValue pvalToSet );
200200
public delegate uint SciterGetVariable ( IntPtr hwndOrNull, [MarshalAs ( UnmanagedType.LPStr )] string name, ref SciterValue pvalToGet );
201-
public delegate uint SciterElementUnwrap ( SciterValue pval, IntPtr ppElement );
202-
public delegate uint SciterElementWrap ( SciterValue pval, IntPtr pElement );
201+
public delegate uint SciterElementUnwrap ( SciterValue pval, ref IntPtr ppElement );
202+
public delegate uint SciterElementWrap ( ref SciterValue pval, IntPtr pElement );
203203

204204
public delegate uint SciterNodeUnwrap ( IntPtr pval /* const VALUE* */, IntPtr ppNode /* HNODE* */ );
205205
public delegate uint SciterNodeWrap ( IntPtr pval /* VALUE* */, IntPtr pNode /* HNODE */ );

src/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"profiles": {
3-
"SciterLibraryAPI": {
3+
"Example": {
44
"commandName": "Project"
55
}
66
}

0 commit comments

Comments
 (0)