I wonder if this possible:
I have added my own button (see follow), and now I wonder if I can change button background color dynamically upon click.
The idea is to simulate a check box enable/disable.
exporting: {
enabled: true,
buttons: {
'realTimeButton': {
id: 'realTimeButton',
symbol: 'diamond',
x: -62,
symbolFill: '#B5C9DF',
hoverSymbolFill: '#779ABF',
_titleKey: "realTimeButtonTitle",
onclick: function() {
// handle change to real time
if ( enable_lastRoundsChart_realtime )
{
enable_lastRoundsChart_realtime = 0;
}
else
{
enable_lastRoundsChart_realtime = 1;
}
}
}
}
It is not possible in simple way, but you can use renderer to prepare your own button and hover / pressed styles.
http://jsfiddle.net/AvpDk/
normalState = new Object();
normalState.stroke_width = null;
normalState.stroke = null;
normalState.fill = null;
normalState.padding = null;
normalState.r = null;
hoverState = new Object();
hoverState = normalState;
hoverState.fill = 'red';
pressedState = new Object();
pressedState = normalState;
var custombutton = chart.renderer.button('button', 74, 10, function(){
alert('aaa');
},null,hoverState,pressedState).add();
Related
I am using colyseus and adding gltf model as a character. So, I need to sync the character position perfectly I am able to get position inside import mesh only which is not so proper for sending and setting the positional data model.
I'm using this playground
This I've added as a question in babylon forum
createScene = function () {
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.FreeCamera(
"camera1",
new BABYLON.Vector3(0, 5, -10),
scene
);
// Targeting the camera to scene origin
camera.setTarget(new BABYLON.Vector3.Zero());
// Attaching the camera to canvas
camera.attachControl(canvas, true);
var light = new BABYLON.HemisphericLight(
"light1",
new BABYLON.Vector3(0, 1, 0),
scene
);
//create a built-in "sphere" shape; its constructor takes 6 params: name, segment, diameter, scene, updatable, sideOrientation
var sphere = BABYLON.MeshBuilder.CreateSphere("Sphere", {diameter: 2, segments: 32}, scene);
// Move the Sphere upward meanse in y axis
sphere.position.y = 1;
var inputMap = {};
// This sceneloader is for loading gltf models it constructor takes : location, name, scene
var character = BABYLON.SceneLoader.ImportMesh(
"",
"https://ak228212.github.io/babylonJs/assets/undercover_cop_-_animated/",
"scene.gltf",
scene,
async function (newMeshes, particleSystems, skeletons, animationGroups) {
try {
var dude = newMeshes[0];
var animations = animationGroups;
console.log(animations);
var idleRange = animations[2];
var walkRange = animations[0];
var breathingIdleRange = animations[1];
animations[0].stop();
dude.position = new BABYLON.Vector3(1.5, 1, 0);
scene.actionManager = new BABYLON.ActionManager(scene);
scene.actionManager.registerAction(
new BABYLON.ExecuteCodeAction(
BABYLON.ActionManager.OnKeyDownTrigger,
function (evt) {
inputMap[evt.sourceEvent.key] =
evt.sourceEvent.type == "keydown";
}
)
);
scene.actionManager.registerAction(
new BABYLON.ExecuteCodeAction(
BABYLON.ActionManager.OnKeyUpTrigger,
function (evt) {
inputMap[evt.sourceEvent.key] =
evt.sourceEvent.type == "keydown";
}
)
);
scene.onBeforeRenderObservable.add(() => {
if (inputMap["ArrowUp"]) {
dude.position.z += 0.1;
animations[0].play();
}
if (inputMap["ArrowLeft"]) {
dude.position.x -= 0.1;
animations[0].play();
dude.rotation.y -= 90;
}
if (inputMap["ArrowDown"]) {
dude.position.z -= 0.1;
animations[0].play();
dude.rotation.y += 180;
}
if (inputMap["ArrowRight"]) {
dude.position.x += 0.1;
animations[0].play();
dude.rotation.y += 90;
}
// scene.createDefaultCameraOrLight(true, true, true);
// scene.createDefaultEnvironment();
//Adding follow Camera
});
} catch (e) {
console.log(e);
}
}
);
// create a built-in "ground" shape;
var ground = BABYLON.MeshBuilder.CreateGround("ground1", {width:20, height:10}, scene);
// To add the texture
var groundTexture = new BABYLON.StandardMaterial("grounfTexture", scene);
// Give the location of texture
groundTexture.diffuseTexture = new BABYLON.Texture(
"https://dl.dropbox.com/s/hrnnq3mv0w3yqo9/ground_texture.jpg",
scene
);
ground.material = groundTexture;
return scene;
};
I have been trying to add images to an array and then access their properties to change their source image in a loop.
Detailed: I create a grid with a layout for each for each grid element, in that layout there is a GridImage, who's source folder is set to "ClosedFolder.png", when I click one of the layouts it should change the clicked layouts folder to "OpenFolder.png".
for (int eachCount = 0; eachCount <= MaxRows / MaxCols; eachCount++)
{
Selectedrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(80, GridUnitType.Absolute) });
for (int newCol = 0; newCol <= MaxCols; newCol++)
{
for (int newRow = 0; newRow <= MaxRows / MaxCols; newRow++)
{
if (folderIndex >= DirectoryArrayList.Count) { break; }
var folder = DirectoryArrayList[folderIndex];
var label = new Label()
{
Text = folder.Name,
FontSize = 12,
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.Center
};
var GridImage = new Image() { Source = "ClosedFolder.png", StyleId = "Image" };
var GridTap = new TapGestureRecognizer();
var Layout = new StackLayout() { StyleId = "StackContent" };
var folderSelection = _mainFolder + "/" + folder.Name;
GridTap.Tapped += async(object sender, EventArgs e) =>
{
FileHandler.CreateTextFiles(folderSelection, "File_" + FileID + ".txt");
files = FolderOptions.AddFilesToList(folderSelection);
lst.ItemsSource = files;
//foreach (Image img in ImageList) I know this i incorrect, just an example of what I think!
//{
// img.Source = "ClosedFolder.png";
//}
GridImage.Source = "OpenFolder.png"; // clicked layout gets its openfolder.png
};
Layout.Children.Add(label);
Layout.Children.Add(GridImage);
Layout.GestureRecognizers.Add(GridTap);
Selectedrid.Children.Add(Layout, newCol, newRow);
folderIndex += 1;
FileID += 1;
}
}
}
Not sure on the declaration of the array and how to implement it.
I added the following into my BasicGrid method ...
var GridImage = new Image() { Source = "ClosedFolder.png", StyleId = "Image" };
var ImageList = new List<Image>{};
ImageList.Add( GridImage );
for (var i = 0; i < ImageList.Count; i++)
{
var img = ImageList[i];
img.Source = "ClosedFolder.png";
} GridImage.Source = "OpenFolder.png"
Just adding to say that Jason's information is the most likely direction I will go in, but as I am still learning it will take me time and I dint want to keep this open while I do that :-)
I working with tabpane. I want to make the tabs detachable. The problem might is the dragboard.
I tried to use MouseRelease event on the tab's graphic to detect its position but its only work when I remove the drag events:
graphic.setOnMouseReleased(e -> {
Point2D mouseLoc = new Point2D(e.getScreenX(), e.getScreenY());
Window window = tabPane.getScene().getWindow();
Rectangle2D windowBounds = new Rectangle2D(window.getX(), window.getY(), window.getWidth(), window.getHeight());
if(!windowBounds.contains(mouseLoc)){
System.out.println("new stage");
}
});
My drag events are working perfectly. I use this method to add handlers to the tabs:
public void addDragHandlers(Tab tab) {
javafx.scene.control.Label label = new javafx.scene.control.Label(tab.getText(), tab.getGraphic());
if (tab.getText() != null && !tab.getText().isEmpty()) {
tab.setText(null);
tab.setGraphic(label);
}
Node graphic = tab.getGraphic();
graphic.setOnMouseReleased(e -> {
Point2D mouseLoc = new Point2D(e.getScreenX(), e.getScreenY());
Window window = tabPane.getScene().getWindow();
Rectangle2D windowBounds = new Rectangle2D(window.getX(), window.getY(), window.getWidth(), window.getHeight());
if(!windowBounds.contains(mouseLoc)){
System.out.println("new stage");
}
});
graphic.setOnDragDetected(e -> {
Dragboard dragboard = graphic.startDragAndDrop(TransferMode.MOVE);
ClipboardContent content = new ClipboardContent();
content.putString(draggingID);
dragboard.setContent(content);
dragboard.setDragView(graphic.snapshot(null, null));
currentDraggingTab = tab;
});
graphic.setOnDragOver(e -> {
if (draggingID.equals(e.getDragboard().getString()) &&
currentDraggingTab != null &&
currentDraggingTab.getGraphic() != graphic) {
e.acceptTransferModes(TransferMode.MOVE);
}
});
graphic.setOnDragDropped(e -> {
if (draggingID.equals(e.getDragboard().getString()) &&
currentDraggingTab != null &&
currentDraggingTab.getGraphic() != graphic) {
int index = tab.getTabPane().getTabs().indexOf(tab);
currentDraggingTab.getTabPane().getTabs().remove(currentDraggingTab);
tab.getTabPane().getTabs().add(index, currentDraggingTab);
currentDraggingTab.getTabPane().getSelectionModel().select(currentDraggingTab);
}
});
graphic.setOnDragDone(e -> currentDraggingTab = null);
}
How can I implement the detach feature inside the drag handler?
Thanks for the help and sorry for my bad english!
I'm writing a script in ExtendScript and need to have tons of checkboxes on a panel inside a tab, I can't split the panel into groups because I need to get the length property of the group.
I was wondering if anyone had experienced an issue with trying to use manual layout with Tabbed panels in ScriptUI.
Is there a way to align children of a tab panel manually?
Here's an example without tabs:
function MakeaPanel(this_obj_) {
var pan = (this_obj_ instanceof Panel)
? this_obj_
: new Window('palette', 'MainWindow',[449,210,831,576]);
CheckBGroup = pan.add('panel', [33,46,350,145], 'CheckBoxGroup', {borderStyle: "etched"});
ChkBox_1 = CheckBGroup.add('checkbox', [18,21,162,41], 'CheckBox1');
ChkBox_1.value = false;
ChkBox_2 = CheckBGroup.add('checkbox', [18,43,162,63], 'CheckBox2');
ChkBox_2.value = false;
ChkBox_3 = CheckBGroup.add('checkbox', [142,21,286,41], 'CheckBox3');
ChkBox_3.value = false;
ChkBox_4 = CheckBGroup.add('checkbox', [142,43,286,63], 'CheckBox4');
ChkBox_4.value = false;
return pan
}
var w = MakeaPanel(this);
if (w.toString() == "[object Panel]") {
w;
} else {
w.show();
}
And Here's an example with Tabs:
function MakeaPanel(this_obj_) {
var pan = (this_obj_ instanceof Panel)
? this_obj_
: new Window('palette', 'MainWindow', undefined); // [449,210,831,576]
var tpanel = pan.add ("tabbedpanel");
var MainTab = tpanel.add ("tab", undefined, "Main");
var OptionsTab = tpanel.add ("tab", undefined, "Options");
var OT_Panel = OptionsTab.add ("panel", undefined, "");
CheckBGroup = MainTab.add('panel', [33,46,350,200], 'CheckBoxGroup', {borderStyle: "etched"});
ChkBox_1 = CheckBGroup.add('checkbox', [18,21,162,41], 'CheckBox1');
ChkBox_1.value = false;
ChkBox_2 = CheckBGroup.add('checkbox', [18,43,162,63], 'CheckBox2');
ChkBox_2.value = false;
ChkBox_3 = CheckBGroup.add('checkbox', [142,21,286,41], 'CheckBox3');
ChkBox_3.value = false;
ChkBox_4 = CheckBGroup.add('checkbox', [142,43,286,63], 'CheckBox4');
ChkBox_4.value = false;
return pan
}
var w = MakeaPanel(this);
if (w.toString() == "[object Panel]") {
w;
} else {
w.show();
}
Hi i am trying to show my popup on the image mouse over
it is showing fine
when i trying mouse over right side last images popup is going out of the screen
Here TalentInfoPopUp is **TitleWindow
This is my sample code
private static var staticWindow :TalentInfoPopUp = null;
private static var visibleWindow:TalentInfoPopUp = null;
public static function show(t:Object, parent : DisplayObject, x:Number , y:Number):void
{
if(staticWindow == null)
{
visibleWindow = staticWindow = PopUpManager.createPopUp( parent , TalentInfoPopUp , false) as TalentInfoPopUp;
}
else if(visibleWindow == null)
{
visibleWindow = staticWindow;
PopUpManager.addPopUp(staticWindow, parent, false);
}
PopUpManager.centerPopUp(staticWindow);
staticWindow.talent = t;
staticWindow.x = x;
staticWindow.y =y;
PopUpManager.bringToFront(staticWindow);
staticWindow.talent = t;
staticWindow.move(x,y);
staticWindow.callLater(staticWindow.setPosition,[x,y]);
//staticWindow.setPosition(x,y);
}
private function setPosition(nx:int,ny:int):void
{
var maxWidth:int = stage.width ;
var maxHeight:int = stage.height;
if(nx>maxWidth-width)
{
nx=nx-width;
}
if(ny>maxHeight-height)
{
ny=ny-height;
}
this.move(nx,ny);
}
Try using systemManager.screen.width and systemManager.screen.height instead of stage.width and stage.height; also learn about the localToGlobal and globalToLocal methods and how to use them.