added back button sounds because SOMEONE fucked it up.....

This commit is contained in:
michiel
2025-12-02 11:51:00 +01:00
parent 9f55f8e1c7
commit 4dbc4997a0
2 changed files with 33 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
package org.toop.app.widget;
import javafx.scene.image.ImageView;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.resource.resources.ImageAsset;
import org.toop.local.AppContext;
@@ -73,8 +75,11 @@ public final class Primitive {
}
if (onAction != null) {
button.setOnAction(_ ->
onAction.run());
button.setOnAction(_ -> {
onAction.run();
playButtonSound();
System.out.println("HI I got called button");
});
}
return button;
@@ -116,10 +121,16 @@ public final class Primitive {
slider.setValue(value);
if (onValueChanged != null) {
slider.valueProperty().addListener((_, _, newValue) ->
onValueChanged.accept(newValue.intValue()));
slider.valueProperty().addListener((_, _, newValue) -> {
onValueChanged.accept(newValue.intValue());
});
}
slider.setOnMouseReleased(event -> {
playButtonSound();
System.out.println("I got called!");
});
return slider;
}
@@ -137,8 +148,11 @@ public final class Primitive {
}
if (onValueChanged != null) {
choice.valueProperty().addListener((_, _, newValue) ->
onValueChanged.accept(newValue));
choice.valueProperty().addListener((_, _, newValue) -> {
onValueChanged.accept(newValue);
playButtonSound();
System.out.println("hi i got called choice");
});
}
choice.setItems(FXCollections.observableArrayList(items));
@@ -191,4 +205,8 @@ public final class Primitive {
return vbox;
}
private static void playButtonSound() {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).postEvent();
}
}

View File

@@ -2,6 +2,8 @@ package org.toop.app.widget.complex;
import org.toop.app.widget.Primitive;
import org.toop.app.widget.Widget;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import org.toop.local.AppContext;
import java.util.function.Consumer;
@@ -30,6 +32,7 @@ public class ToggleWidget implements Widget {
updateText();
if (onToggle != null) {
onToggle.accept(state);
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).postEvent(); // TODO FIX PRIMITIVES
}
});