[curr_val, sample_bin, quit] = inputFunc_object(input_device, ... last_val, respmap, input_args, trial_bin, sample_bin)
INPUTFUNC_OBJECT illustrates the use of more complex input_funcs, as well as the hierarchical use of input funcs. Its intended function is to update positions of draggable objects. An object is "dragged" when the user presses the left mouse button on top of an object and holds the button down while moving the mouse. Note how INPUTFUNC_OBJECT makes a call to inputFunc_mouse to obtain the necessary cursor information.
INPUTFUNC_OBJECT manages the positions of objects as manipulated using cursor input. Each curr_val sample contains dimensionality 5+2n, where n is the number of objects, and takes the form: [mouse_x mouse_y l_click r_click active_object obj1_x obj1_y obj2_x...] ...where obj1_x and obj1_y represent the current top-left corner of that object's screen position. To use INPUTFUNC_OBJECT, supply standard input_func form of input and output arguments. In parcticular, use the syntax shown above with arguments: input_device: a cursor device token (e.g., as provided by easyLaunch or getInputDevice). last_val: the recent history or initialization value of INPUTFUNC_OBJECT (must take dimensionality [m 5+2n] as above, where m is any number of rows, although only the final row is referenced). respmap: response map as generated by makeMap, where each row corresponds to an object that is named in the descriptors field, labeled in the values field, and in the inputs field consists of a rect describing its screen position with the form [min_x min_y max_x max_y]). input_args: the mode in which INPUTFUNC_OBJECT functions is controlled by arguments passed through this cell array. Arguments are as follows: 1-4: equivalent to inputFunc_mouse (see help inputFunc_mouse). 5: boolean: when true, objects are not allowed to pass beyond the canvas boundaries. When false, objects may be dragged beyond the border and up until the point that the mouse collides with the border. trial_bin: Trial-specific information as follows: 3: when specified, all objects will be dragged as a group, no matter which object is selected. sample_bin: As with all input_funcs, the sample bin is a cell array with two elements: an INPUT_BIN in position one, and a DISPLAY_BIN in position two. It is normally initialized and handled by easyScale, and gets updated by INPUTFUNC_OBJECT each time the function is called. The contents of the INPUT_BIN are unique to INPUTFUNC_OBJECT and are as follows: 1: an updated version of the respmap that was initially provided that contains the new object positions. 2: an array of the top-left corners of objects. 3: an array indicating the "stack order" of the objects, corresponding to the order in which they were most recently selected. INPUTFUNC_OBJECT produces the following outputs: curr_val: a size [1 5+n*2] vector representing object states as above. sample_bin: updated version of the sample_bin supplied as input (above). quit: a boolean that is always false.
For example usage of INPUTFUNC_OBJECT, please see demoEasyScale_drag.