Comments (3)
update with type conversion.
language:
Blockly.Language.text_prompt = {
// Prompt statement.
category: 'Text',
helpUrl: 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode92.html',
init: function() {
this.setColour(160);
this.appendTitle('read');
var menu = new Blockly.FieldDropdown(this.OPERATORS);
this.appendTitle(menu, 'TYPE');
this.appendInput('', Blockly.INPUT_VALUE, 'TEXT');
this.setOutput(true);
this.setTooltip('Prompt for user input with the specified text.');
}
};
Blockly.Language.text_prompt.OPERATORS =
[['string', 'STRING'], ['integer', 'INTEGER']];
python generator:
Blockly.Python.text_prompt = function() {
// prompt a user input dialog.
var mode = this.getTitleValue('TYPE');
console.log(mode);
var operator = Blockly.Python.text_prompt.OPERATORS[mode];
var argument0 = Blockly.Python.valueToCode(this, 'TEXT', true) || '\'\'';
return operator+'(raw_input(' + argument0 + '));\n';
};
Blockly.Python.text_prompt.OPERATORS = {
STRING: 'str',
INTEGER: 'int'
};
Original comment by gasolin
on 16 Jun 2012 at 8:02
from blockly.
Issue 29 has been merged into this issue.
Original comment by gasolin
on 16 Jun 2012 at 8:06
from blockly.
Done in r260 and r261.
Modal I/O is a terrible UI experience. As such, Print and Prompt should be
treated as emergency functions. Any real environment would have much better
I/O APIs. But they are still very useful for debugging and "Hello World"
applications.
Since this is an emergency debugging function, I've converted the prompt
message input into an inline field. This is simpler and sufficient most of the
time. If one really wants a dynamically customizable message field, then one
should probably be using a better API.
Type conversion functions are also something we need, but I've folded them into
this block, again for convenience.
The use of window.prompt in Dart is questionable. It will only work in a
browser, not in the command-line version. Likewise there's a complicated
asynchronous readLine version that only works in the command-line version and
not the browser.
Original comment by [email protected]
on 19 Jun 2012 at 1:01
- Changed state: Fixed
from blockly.
Related Issues (20)
- Number of app's lang-manu HOT 2
- turtle trail does not show on Android Nexus 10
- Blockly.Xml.workspaceToDom doesn´t work on Safari HOT 2
- context menu on tablets HOT 1
- Non Printing Text Characters
- [deleted issue]
- [deleted issue]
- Color dropdowns not listening for touch events HOT 1
- Trashcan Lid animation uses CPU when idle HOT 1
- Uncollapsing duplicated block "Connection already in database" error HOT 2
- Code blocks can become misaligned when moving a set of blocks with a "break out of loop" attached to it out of a loop HOT 1
- Mouse wheel scrolling fails to scroll blockly scroll bars up or down HOT 1
- Blocky GUI is pushed from view when a long text string is entered into a block HOT 1
- If block breaks when click on the star. HOT 1
- Blockly games not running correctly on chrome! HOT 4
- Headless blockly doesn't work for function/procedure calls with parameters HOT 1
- How to create types to restrict connections between few custom blocks? HOT 1
- change name on google + HOT 1
- Left-Right-Up-Down movement in Blockly JS HOT 1
- testing window['Audio'] is not sufficient HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blockly.