Skip to content

Commit 0d3334a

Browse files
committed
Add tooltips
1 parent 0871778 commit 0d3334a

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

src/blocks/mrc_mechanism_component_holder.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,16 @@ const MECHANISM_COMPONENT_HOLDER = {
8282
this.setInputsInline(false);
8383
this.appendStatementInput(INPUT_MECHANISMS).setCheck(MECHANISM_OUTPUT).appendField(Blockly.Msg.MECHANISMS);
8484
this.appendStatementInput(INPUT_COMPONENTS).setCheck(COMPONENT_OUTPUT).appendField(Blockly.Msg.COMPONENTS);
85-
this.appendStatementInput(INPUT_PRIVATE_COMPONENTS).setCheck(COMPONENT_OUTPUT).appendField(Blockly.Msg.PRIVATE_COMPONENTS);
85+
const privateComponentsInput = this.appendStatementInput(INPUT_PRIVATE_COMPONENTS).setCheck(COMPONENT_OUTPUT).appendField(Blockly.Msg.PRIVATE_COMPONENTS);
86+
// Set tooltip on the private components field
87+
const privateComponentsField = privateComponentsInput.fieldRow[0];
88+
if (privateComponentsField) {
89+
privateComponentsField.setTooltip(Blockly.Msg.PRIVATE_COMPONENTS_TOOLTIP);
90+
}
8691
this.appendStatementInput(INPUT_EVENTS).setCheck(EVENT_OUTPUT).appendField(Blockly.Msg.EVENTS);
92+
93+
// Update components tooltip based on private components visibility
94+
this.updateComponentsTooltip_();
8795

8896
this.setOutput(false);
8997
this.setStyle(MRC_STYLE_MECHANISMS);
@@ -112,6 +120,21 @@ const MECHANISM_COMPONENT_HOLDER = {
112120
this.mrcHidePrivateComponents = (extraState.hidePrivateComponents == undefined) ? false : extraState.hidePrivateComponents;
113121
this.updateBlock_();
114122
},
123+
/**
124+
* Update the components tooltip based on private components visibility.
125+
*/
126+
updateComponentsTooltip_: function (this: MechanismComponentHolderBlock): void {
127+
const componentsInput = this.getInput(INPUT_COMPONENTS);
128+
if (componentsInput && componentsInput.fieldRow[0]) {
129+
const componentsField = componentsInput.fieldRow[0];
130+
// Only show tooltip if private components are also visible (not hidden)
131+
if (!this.mrcHidePrivateComponents) {
132+
componentsField.setTooltip(Blockly.Msg.COMPONENTS_TOOLTIP);
133+
} else {
134+
componentsField.setTooltip('');
135+
}
136+
}
137+
},
115138
/**
116139
* Update the block to reflect the newly loaded extra state.
117140
*/
@@ -137,10 +160,18 @@ const MECHANISM_COMPONENT_HOLDER = {
137160
}
138161
else {
139162
if (this.getInput(INPUT_PRIVATE_COMPONENTS) == null) {
140-
this.appendStatementInput(INPUT_PRIVATE_COMPONENTS).setCheck(COMPONENT_OUTPUT).appendField(Blockly.Msg.PRIVATE_COMPONENTS);
163+
const privateComponentsInput = this.appendStatementInput(INPUT_PRIVATE_COMPONENTS).setCheck(COMPONENT_OUTPUT).appendField(Blockly.Msg.PRIVATE_COMPONENTS);
164+
// Set tooltip on the field
165+
const privateComponentsField = privateComponentsInput.fieldRow[0];
166+
if (privateComponentsField) {
167+
privateComponentsField.setTooltip(Blockly.Msg.PRIVATE_COMPONENTS_TOOLTIP);
168+
}
141169
this.moveInputBefore(INPUT_PRIVATE_COMPONENTS, INPUT_EVENTS)
142170
}
143171
}
172+
173+
// Update components tooltip based on private components visibility
174+
this.updateComponentsTooltip_();
144175
},
145176
onBlockChanged: function (block: Blockly.BlockSvg, blockEvent: Blockly.Events.BlockBase) {
146177
if (blockEvent.type == Blockly.Events.BLOCK_MOVE) {

src/blocks/tokens.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export function customTokens(t: (key: string) => string): typeof Blockly.Msg {
3838
MECHANISMS: t('MECHANISMS'),
3939
OPMODES: t('OPMODES'),
4040
COMPONENTS: t('BLOCKLY.COMPONENTS'),
41+
COMPONENTS_TOOLTIP: t('BLOCKLY.TOOLTIP.COMPONENTS'),
4142
PRIVATE_COMPONENTS: t('BLOCKLY.PRIVATE_COMPONENTS'),
43+
PRIVATE_COMPONENTS_TOOLTIP: t('BLOCKLY.TOOLTIP.PRIVATE_COMPONENTS'),
4244
EVENTS: t('BLOCKLY.EVENTS'),
4345
EVALUATE_BUT_IGNORE_RESULT: t('BLOCKLY.EVALUATE_BUT_IGNORE_RESULT'),
4446
EVALUATE_BUT_IGNORE_RESULT_TOOLTIP:

src/i18n/locales/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
"OPMODE_TYPE": "What sort of OpMode this is",
6363
"OPMODE_ENABLED": "Whether the OpMode is shown on Driver Station",
6464
"OPMODE_NAME": "The name shown on the Driver Station. If blank will use the class name.",
65-
"OPMODE_GROUP": "An optional group to group OpModes on Driver Station"
65+
"OPMODE_GROUP": "An optional group to group OpModes on Driver Station",
66+
"COMPONENTS": "These components are visible in this mechanism, the robot, and all opmodes.",
67+
"PRIVATE_COMPONENTS": "These components will not be visible in the robot or opmodes. They are only accessible within this mechanism."
6668
},
6769
"CATEGORY":{
6870
"LISTS": "Lists",

src/i18n/locales/es/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
"OPMODE_TYPE": "Qué tipo de OpMode es este",
6464
"OPMODE_ENABLED": "Si el OpMode se muestra en la Estación del Conductor",
6565
"OPMODE_NAME": "El nombre mostrado en la Estación del Conductor. Si está en blanco usará el nombre de la clase.",
66-
"OPMODE_GROUP": "Un grupo opcional para agrupar OpModes en la Estación del Conductor"
66+
"OPMODE_GROUP": "Un grupo opcional para agrupar OpModes en la Estación del Conductor",
67+
"COMPONENTS": "Estos componentes son visibles en este mecanismo, el robot y todos los opmodes.",
68+
"PRIVATE_COMPONENTS": "Estos componentes no serán visibles en el robot o en los opmodes. Solo son accesibles dentro de este mecanismo."
6769
},
6870
"CATEGORY": {
6971
"LISTS": "Listas",

src/i18n/locales/he/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
"OPMODE_TYPE": "איזה סוג של מצב פעולה זה",
6363
"OPMODE_ENABLED": "האם מצב הפעולה מוצג בתחנת הנהג",
6464
"OPMODE_NAME": "השם המוצג בתחנת הנהג. אם ריק ישתמש בשם הכיתה.",
65-
"OPMODE_GROUP": "קבוצה אופציונלית לקיבוץ מצבי פעולה בתחנת הנהג"
65+
"OPMODE_GROUP": "קבוצה אופציונלית לקיבוץ מצבי פעולה בתחנת הנהג",
66+
"COMPONENTS": "רכיבים אלה גלויים במנגנון זה, ברובוט ובכל מצבי הפעולה.",
67+
"PRIVATE_COMPONENTS": "רכיבים אלה לא יהיו גלויים ברובוט או במצבי פעולה. הם נגישים רק בתוך המנגנון הזה."
6668
},
6769
"CATEGORY":{
6870
"LISTS": "רשימות",

0 commit comments

Comments
 (0)