Go to: Synopsis. Return value. Keywords. MEL examples.
hitTest stringintint
hitTest is NOT undoable, NOT queryable, and NOT editable.
The hitTest command hit-tests a point in the named control and returns a list of items underneath the point. The point is specified in pixels with the origin (0,0) at the top-left corner. This position is compatible with the coordinates provided by a drop-callback. The types of items that may be returned depends upon the specific control; not all controls currently support hit-testing.string[] | items underneath the hit-point |
// Let's say that you have the name of a model editor that was // created elsewhere. // string $editor = "MyModelEditor"; // // Attach a drop callback to this model editor. // string $control = `editor -query -control $editor`; if (($control != "") && `control -exists $control`) { control -edit -dropCallback ("myModelEditorDropCallback") $control; } // // Here's your drop callback: // global proc myModelEditorDropCallback( string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type) { // Inside the callback we can hit-test the (x,y) drop-point // against the control. This will return a list of DAG objects // underneath the drop-point. // string $objects[] = hitTest($dropControl, $x, $y); if (size($objects) > 0) { // The hit-test returned something. You can now do something // with these objects. } }