hai @ewpatton
could you please help me with this
Short of doing the work for you (which I won't), I'm not certain what exactly you need. If you look at the implementation of the function you will see how we address the issue of switching between non-visible workspaces. You will need to adapt that logic to your own system.
sorry for the inconvenience, i will explain point in detail
as you said
i found BlocklyPanel.makeActive
in BlocklyPanel.java file at makeActive() class
that code i implemented in javascript window resize event listener
the code is given below
1. window.addEventListener('resize',function(e){
2.
3. Blockly.mainWorkspace.refreshBackpack();
4. if (Blockly.mainWorkspace.pendingRender) {
5. Blockly.mainWorkspace.pendingRenderFunc();
6. }
7. // Trigger a screen switch to send new YAIL.
8.var parts = Blockly.mainWorkspace.formName.split(/_(.+)/); // Split string on first _
9. if (Blockly.ReplMgr.isConnected()) {
10. Blockly.ReplMgr.pollYail(Blockly.mainWorkspace);
11. }
12. Blockly.mainWorkspace.fireChangeListener(new AI.Events.ScreenSwitch(parts[0], parts[1]));
13.});
in the above code in line number 4. Blockly.mainWorkspace.pendingRender
is returns null
with this code the invisible worksheet is not getting visible after window resize when worksheet is invisible
====================================================================
====================================================================
My another problem is
when a block is drag and dropped on the backpack then the block is added to backpack.
But it is not returning to its previous position
Blockly.Backpack.prototype.onMouseUp = function(e, start){
start.x = e.clientX;
start.y = e.clientY;
var xy = Blockly.selected.getRelativeToSurfaceXY();
var diffXY = goog.math.Coordinate.difference(start, xy);
Blockly.selected.moveBy(diffXY.x, diffXY.y);
Blockly.getMainWorkspace().render();
console.log(diffXY,xy);
};
In the above code the start paramater of Blockly.Backpack.prototype.onMouseUp
event the value in start parameter is got as `{x:"undefined",y:"undefined"}
Is there any solution to rectify it
Hoping with a positive response
Regards @suryaprakash_lokula
what exactly you want to do?
app inventor workspace is designed for app inventor.
you can also create your own workspace with new features and new blocks also.
Regarding your first item, you may also want to make sure you invoke the resize()
method before calling render()
.
Regarding your second item, if you're using a newer version of Blockly it's possible that the same information is no longer sent to the backpack as before. You'll have to look at the version of Blockly you're using and compare it to the version App Inventor is built with to determine what changed there.
Thank you @ewpatton
i have tried that but not working
window.addEventListener('resize',function(e){
workspace.refreshBackpack();
workspace.resize();
workspace.pendingRender = true
if (workspace.pendingRender) {
workspace.pendingRenderFunc();
}
// Trigger a screen switch to send new YAIL.
var parts = workspace.formName.split(/_(.+)/); // Split string on first _
workspace.fireChangeListener(new AI.Events.ScreenSwitch(parts[0], parts[1]));
});
No i am using the old version of blockly which is used by appinventor
All you've done is add an event listener. That doesn't actually invoke any of the code written there. You have to separately call workspace.resize()
elsewhere in your setup code once the workspace is visible.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.