diff options
-rw-r--r-- | src/bltGrAxis.C | 16 | ||||
-rw-r--r-- | src/bltGrLegdOp.C | 24 | ||||
-rw-r--r-- | tests/legend.tcl | 1 |
3 files changed, 19 insertions, 22 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 70985b8..c9b784d 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -1051,20 +1051,18 @@ static int AxisDeleteOp(Tcl_Interp* interp, Graph* graphPtr, static int AxisFocusOp(Tcl_Interp* interp, Graph* graphPtr, int objc, Tcl_Obj* const objv[]) { - if (objc > 3) { - Axis *axisPtr = NULL; - const char *string = Tcl_GetString(objv[3]); - if ((string[0] != '\0') && - (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK)) + graphPtr->focusPtr = NULL; + if (objc == 4) { + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) return TCL_ERROR; - graphPtr->focusPtr = NULL; if (axisPtr && !axisPtr->hide && axisPtr->use) graphPtr->focusPtr = axisPtr; - - Blt_SetFocusItem(graphPtr->bindTable, graphPtr->focusPtr, NULL); } - /* Return the name of the axis that has focus. */ + + Blt_SetFocusItem(graphPtr->bindTable, graphPtr->focusPtr, NULL); + if (graphPtr->focusPtr) Tcl_SetStringObj(Tcl_GetObjResult(interp), graphPtr->focusPtr->obj.name,-1); diff --git a/src/bltGrLegdOp.C b/src/bltGrLegdOp.C index 8a6d97e..848ee0c 100644 --- a/src/bltGrLegdOp.C +++ b/src/bltGrLegdOp.C @@ -263,25 +263,23 @@ static int FocusOp(Graph* graphPtr, Tcl_Interp* interp, { Legend* legendPtr = graphPtr->legend; + legendPtr->focusPtr_ = NULL; if (objc == 4) { Element* elemPtr; - if (legendPtr->getElementFromObj(objv[3], &elemPtr) != TCL_OK) return TCL_ERROR; - if ((elemPtr != NULL) && (elemPtr != legendPtr->focusPtr_)) { - /* Changing focus can only affect the visible entries. The entry - * layout stays the same. */ + if (elemPtr) legendPtr->focusPtr_ = elemPtr; - } - Blt_SetFocusItem(legendPtr->bindTable_, legendPtr->focusPtr_, - CID_LEGEND_ENTRY); - graphPtr->legend->eventuallyRedraw(); - } - if (legendPtr->focusPtr_) { - Tcl_SetStringObj(Tcl_GetObjResult(interp), - legendPtr->focusPtr_->name(), -1); } + + Blt_SetFocusItem(legendPtr->bindTable_, legendPtr->focusPtr_, + CID_LEGEND_ENTRY); + graphPtr->legend->eventuallyRedraw(); + + if (legendPtr->focusPtr_) + Tcl_SetStringObj(Tcl_GetObjResult(interp),legendPtr->focusPtr_->name(),-1); + return TCL_OK; } @@ -311,7 +309,7 @@ static Blt_OpSpec legendOps[] = {"configure", 2, (void*)ConfigureOp, 3, 0, "?option value?...",}, {"curselection", 2, (void*)CurselectionOp, 3, 3, "",}, {"deactivate", 1, (void*)ActivateOp, 3, 0, "?pattern?...",}, - {"focus", 1, (void*)FocusOp, 4, 4, "elem",}, + {"focus", 1, (void*)FocusOp, 3, 4, "?elem?",}, {"get", 1, (void*)GetOp, 4, 4, "elem",}, {"selection", 1, (void*)SelectionOp, 3, 0, "args"}, }; diff --git a/tests/legend.tcl b/tests/legend.tcl index d729261..5a28ab1 100644 --- a/tests/legend.tcl +++ b/tests/legend.tcl @@ -56,6 +56,7 @@ bltCmd $graph legend configure -fg #bltCmd $graph legend curselection #bltCmd $graph legend deactivate bltCmd $graph legend focus data1 +bltCmd $graph legend focus #bltCmd $graph legend get data1 bltCmd $graph legend selection anchor data1 bltCmd $graph legend selection mark data1 |