Skip to content

Commit

Permalink
added clicky to the function buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
theluqmn committed Dec 27, 2024
1 parent 8095edd commit 7a52215
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 17 additions & 4 deletions src/components/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ export function functionComponent(k) {
functionButton(k, 190, 598);
}

function functionButton(k, x, y, textInput) {
function functionButton(k, x, y, textInput, onClick) {
const button = k.add([
k.rect(56, 28, {
radius: 3
}),
k.pos(x, y),
k.color(10,10,10),
k.anchor("top"),
])
k.area(),
k.scale(1)
]);

const text = k.add([
k.text(textInput, {
Expand All @@ -55,6 +57,17 @@ function functionButton(k, x, y, textInput) {
}),
k.pos(x, y + 5),
k.color(255,255,255),
k.anchor("top")
])
k.anchor("top"),
k.scale(1)
]);

button.onClick(() => {
button.scaleTo(0.95);
text.scaleTo(0.95);
setTimeout(() => {
button.scaleTo(1);
text.scaleTo(1);
if (onClick) onClick(); // Run the callback function if it's provided
}, 100);
});
}
4 changes: 2 additions & 2 deletions src/scenes/fms.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default function FMS(k) {
size: 18,
width: 500
}),
k.pos(300, 5),
k.color(0,0,0),
k.pos(300, 910),
k.color(125,125,125),
k.anchor("top")
]);

Expand Down

0 comments on commit 7a52215

Please sign in to comment.