![]() ![]() I don’t really think you need to know this to get things to work at the moment, but you might find the implementation interesting if ever you need to do more complicated work with mouse/keyboard events. ISSelectingArea: The user “right-clicked” on the plot widget, so now mouse moves should be used define the zoom-in area.ISPanningData: The user “shift-clicked” on the plot widget, so now mouse moves should be used to pan the data window.ISMovingΔInfo: In the process of moving an “info box” displaying the difference data between two “position markers”.ISMovingMarker: In the process of moving a “control point” that controls the position of a “position marker”.Depending on what the user has done in the past, the plot widget might be in different states.įor example, I have the following states: I use these structures to handle mouse and keyboard events in InspectDR by modelling a form of state machine. I am not certain you actually wanted to know the backstory of ISNormal, but since you asked…Īn object of type ISNormal is a subtype of the InputState type. These functions/structures/… are not exported by InspectDR - so they are not otherwise available from your own function’s scope. Note that I now had to add a direct reference to InspectDR for all function calls/structure definitions/etc defined in the InspectDR module. Pop-Up Menus One of Swings nifty components is JPopupMenu, a context menu that appears at the mouse location when you press the appropriate mouse button or. InspectDR.handleevent_mousepress(pwidget, InspectDR.CtrlElement, event.x, event.y) #!!! ADD CODE HERE #NOTE: Typically a Point2D struct, but might be nothing. InspectDR.mousepan_setstart(pwidget, event.x, event.y) #Changes stateĮlseif !InspectDR.modifiers_pressed(event.state, InspectDR.MODIFIERS_SUPPORTED) #Un-modified If InspectDR.modifiers_pressed(event.state, InspectDR.MODIFIER_SHIFT) InspectDR.boxzoom_setstart(pwidget, event.x, event.y) #Changes state ![]() InspectDR.focus_strip(pwidget, event.x, event.y) …But since we are talking Julia here, I suppose you could use the “dynamic patching” (guerrilla patch/monkey patch) technique to overwrite the function from your own code, instead of directly modifying the InspectDR code: using InspectDRįunction InspectDR.handleevent_mousepress(::InspectDR.ISNormal, pwidget::InspectDR.PlotWidget, event.state, event.button, event.event_type ![]() I call it a “hack” because you actually have to add your code (or possibly a call to your user-defined function) directly in InspectDR’s src/gtk_input.jl file. Second exampleĪs for the second example: that one will definitively work. I merely included the example in case you better understood how Gtk worked, and knew how to get around the problem. I am almost certain you are supposed to be able to connect multiple callback functions to the same “signal”. I think it is supposed to work, but the "button-press-event" signal already has a connection in the InspectDR code. The first example does not work at the moment. This value is already re-mapped from event (screen coordinates). You can access the last known mouse position using:. Normally, InspectDR uses this event to move “control elements” of markers on the plot. Handleevent_mousepress(pwidget, CtrlElement, event.x, event.y)ĪDD_CODE_HERE runs when the user uses the left mouse button WITHOUT a modifier key being pressed (NOT holding SHIFT, CTRL, or ALT). Mousepan_setstart(pwidget, event.x, event.y) #Changes stateĮlseif !modifiers_pressed(event.state, MODIFIERS_SUPPORTED) #Un-modified If modifiers_pressed(event.state, MODIFIER_SHIFT) Alternative Hackįor the moment, you could “hack in” your own “event handler” in src/gtk_input.jl: function handleevent_mousepress(::ISNormal, pwidget::PlotWidget, event.state, event.button, event.event_typeīoxzoom_setstart(pwidget, event.x, event.y) #Changes state #Define your own callback function cb_mousepress_custom(w::Ptr,), false, pwidget)īut for some reason, I cannot get 2 signals to connect to the same widget. Normally, InspectDR uses this event to move control elements of markers on the plot. #Get a refrence to the base PlotWidget object: The Physical Min/Max describes how the Logical units map onto a Physical 'spectrum'. These values are determined by the Logical Min/Max. That's the bytes that actually flow from device to PC through an IN endpoint. Gplot = display(InspectDR.GtkDisplay(), mplot) So for this example, the HID thermometer would be returning a value between 0-999 in the report. Mplot = InspectDR.Multiplot(title="Quadratic") In theory, you could “connect” your own signal callback function as done in function PlotWidget of src/gtk_top.jl: using InspectDR (Though you might be able to figure it out) SystemPropertiesUtil.resolveSystemProperties() if (OSUtils.At the moment, InspectDR is not structured for this sort of thing - however… Broken Solution ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |