I have the following F# code to handle a Gtk.TreeView event:
tree.CursorChanged.Add(fun (e : EventArgs) ->
let selection = tree.Selection
let mutable iter = new TreeIter ()
if selection.GetSelected(&iter) then
Console.WriteLine("Path of selected row = {0}", model.GetPath(iter))
)
selection.GetSelected
has two overloads, with signatures
bool GetSelected(out TreeIter, out ITreeModel)
and
bool GetSelected(out TreeIter)
which is preventing me from using the tuple-returning version as described in this post:
let selection = tree.Selection
match selection.GetSelected() with
| true, iter -> // success
| _ -> // failure
Is there any way to specify which GetSelected
overload I want with the latter syntax?
Edit: To clarify the question, I know what method signature I want; I just don't know how to specify it. For instance, I tried this, which didn't work:
let f : (byref<TreeIter> -> bool) = selection.GetSelected
match f() with
| true, iter -> // success
| _ -> // failure
When a program calls a function, the program control is transferred to the called function. A called function performs a defined task and when its return statement is executed or when its function-ending closing brace is reached, it returns the program control back to the main program.
Just declare the C function extern "C" (in your C++ code) and call it (from your C or C++ code). For example: // C++ code. extern "C" void f(int); // one way.
The C function always has two arguments, conventionally named self and args. The self argument points to the module object for module-level functions; for a method it would point to the object instance. The args argument will be a pointer to a Python tuple object containing the arguments.
I think
match selection.GetSelected() : bool*_ with
...
should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With