The gWidgets2 package provides a programming interface for making graphical user interfaces within R. The package is a rewrite of the gWidgets package, introducing a few external changes but a significant number of internal ones. The package relies on one of several underlying toolkit packages providing access to the graphical libraries. This package provides the implementation to interface with the underlying tcltk package.
Drag and drop in tcltk is not supported by any underlying toolkit functionality. As such, in gWidgets2tcltk we roll our own. The result is a little limited: a) you can't drop values from other applications b) drop targets aren't allowed to be picky about what they receive (not by mime-type anyways).
GComponent is a parent class for both GContainer and GWidget and inherits its primary interface from gWidgets2::BasicToolkitInterface.
The GDf
class provides a means to edit a data frame. We
use the add on TK code provided by tablelist as the underlying
widget
The main reference methods GTimer
are start_timer
and stop_timer
passed to constructor
is_watching()
Are we watching for a drag?
add_drag_motion(handler, action = NULL, ...)
Called when motion over widget occurs
add_to_parent(parent, child, expand = NULL, fill = NULL, anchor = NULL,
...)
Add a child to parent if it is ia container and non null. Dispatches to add_child method of parent
get_block()
Return surround block
get_enabled()
is widget sensistive to user input
get_index(drop = NULL, ...)
svalue; index=TRUE
get_tk_id()
Return tk ID
get_toplevel_tk_id()
return id of toplevel
get_value(drop = NULL, ...)
Get main value of widget. From `svalue` when index = FALSE or NULL
get_widget()
Return widget (not block)
is_tkwidget()
Is widget older style widget
is_ttkwidget()
Is widget new style widget?. Override in subclass if not
set_enabled(value, ...)
specify with logical if widget is sensistive to user input
set_size(value, ...)
Set widget size (size request), value=c(width=-1, height=-1)
set_value(value, ..., drop = NULL)
for `svalue<-` when index = FALSE or NULL
add(...)
add is just add_child
child_bookkeeping(child)
Update parent property of child and children property of parent container
get_widget()
Return widget (not block)
connect_to_toolkit_signal(signal, decorator, emitter = handler_widget(), ...)
Connect signal of toolkit to notify observer
remove_border()
Remove border by setting relief to none
get_length(...)
Get length of object. Needed for sapply.
save_data(nm, where)
Save data set
set_interval(ms)
Set the interval. Need to stop and start active timer to implement.
start_timer()
Start the timer
stop_timer()
stop the timer
To implement drag and drop, we bind to the toplevel window the events: button1, motion and button1 release. The binding occurs not to to widget, but to the toplevel window containing the widget. This has some advantages, most imporantly it is unlikely the binding will be overwritten by usual gWidgets2tcltk programs. (Recall tkbind will only allow one binding per widget per signal).
The gWidgets2 way of doing drag and drop is implemented here. You
add a drop source with a handler that returns the value of what
you want to pass via the dnd process. Then you specify a widget as
a drop target and give a handler. This handler receives the data
through the dropdata
component of the "h
"
argument. Here, the value is generated when the drop occurs, not
when the drag initiates. Not sure this makes any difference, but
it might.
Simply click on a row and the editor pops up as a modal dialog. The shortcut Shift+Enter will go onto the next case, saving changes provided the auto save featuer is employed.
There is no undo/redo support here. There is no support for editing rownames (just lazy at the moment, holler if you would like that). No support to change the dimensions of the data frame or edit factors, ...