Auto switch behavior details panels

This commit is contained in:
MrKBear 2022-04-04 16:52:42 +08:00
parent a23b5d62cc
commit 4d818988f9
2 changed files with 10 additions and 5 deletions

View File

@ -45,9 +45,9 @@ class BehaviorList extends Component<IBehaviorListProps & IMixinStatusProps & IM
if (this.props.status) {
this.props.status.setBehaviorObject(behavior as Behavior);
}
// if (this.props.setting) {
// this.props.setting.layout.focus("LabelDetails");
// }
if (this.props.setting) {
this.props.setting.layout.focus("BehaviorDetails");
}
this.labelInnerClick = true;
}}
onAdd={() => {

View File

@ -1,6 +1,7 @@
import { Component, ReactNode } from "react";
import { AttrInput } from "@Component/AttrInput/AttrInput";
import { useStatusWithEvent, IMixinStatusProps, Status } from "@Context/Status";
import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status";
import { useSetting, IMixinSettingProps } from "@Context/Setting";
import { Message } from "@Component/Message/Message";
import { ObjectID } from "@Model/Renderer";
import { ColorInput } from "@Component/ColorInput/ColorInput";
@ -25,11 +26,12 @@ const allOption: IDisplayItem[] = [
{nameKey: "Common.Attr.Key.Generation.Mod.Range", key: GenMod.Range}
];
@useSetting
@useStatusWithEvent(
"groupAttrChange", "groupLabelChange", "focusObjectChange",
"focusBehaviorChange", "behaviorChange", "groupBehaviorChange"
)
class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps> {
class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps & IMixinSettingProps> {
private renderFrom(group: Group) {
return <>
@ -122,6 +124,9 @@ class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps> {
}}
action={(behavior) => {
this.props.status?.setBehaviorObject(behavior);
setTimeout(() => {
this.props.setting?.layout.focus("BehaviorDetails");
});
}}
delete={(behavior) => {
this.props.status?.deleteGroupBehavior(group.id, behavior);