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) { if (this.props.status) {
this.props.status.setBehaviorObject(behavior as Behavior); this.props.status.setBehaviorObject(behavior as Behavior);
} }
// if (this.props.setting) { if (this.props.setting) {
// this.props.setting.layout.focus("LabelDetails"); this.props.setting.layout.focus("BehaviorDetails");
// } }
this.labelInnerClick = true; this.labelInnerClick = true;
}} }}
onAdd={() => { onAdd={() => {

View File

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