Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small active area when selecting number fields on blocks #132

Closed
drigz opened this issue Mar 23, 2016 · 6 comments
Closed

Small active area when selecting number fields on blocks #132

drigz opened this issue Mar 23, 2016 · 6 comments
Assignees
Labels

Comments

@drigz
Copy link
Collaborator

drigz commented Mar 23, 2016

scratch-blockly hitbox

To change the number "1" on the block above, you have to click inside the text area of the "1" - clicking in the surrounding white area does nothing. The active area is highlighted in the image above. This is especially hard to hit on touchscreens.

Two possible fixes:

  • Blockly.Field.init() could install the mouseup handler on block.getSvgRoot()
  • or field.borderRect_ could be larger (what it's current purpose? It has width="0" for me)

What do you think is the right approach to improving this?

@tmickel
Copy link
Contributor

tmickel commented Mar 24, 2016

I think the actual block here is being drawn to look like the field. Fix number one makes sense to me, but would make the field incompatible with the vertical text field? If we make borderRect_ larger, can it fill the whole space of the shadow block?

Another possible way to approach it might be to install the handler in the horizontal rendering of the shadow?

@tmickel tmickel added the bug label Mar 29, 2016
@drigz
Copy link
Collaborator Author

drigz commented Mar 30, 2016

Is there a way I can test the vertical rendering at the moment? If I open vertical_playground.html I get broken blocks:

broken vertical rendering

I've looked into the borderRect_ option, which is a little weird. The image below shows a classic Blockly block - the borderRect_ is the lighter green background for the text, which also provides a nice click target. Its width is calculated by Field.render_ to give SEP_SPACE_X/2 margin either side of the text. Field.render_ is normally called by field.getSize(), which the horizontal renderer doesn't use, so the rect never gets a width and is invisible.

blockly classic

As FieldTextInput.resizeEditor_() uses the borderRect_ size (from Field.getAbsoluteXY_()) to determine how to size the <input>, this bug means that the text doesn't quite line up when editing (see below), so I think fixing the borderRect_ rendering is worth it regardless. Doing this will increase the size of the click target, although it won't quite fill the shadow block. The misalignment was introduced by a change I made, the text is properly aligned with vanilla code.

misaligned editor

To make the whole shadow block active, I think we'd need to install the handler differently in horizontal/vertical rendering, although I don't have a feeling for how vertical rendering is meant to work.

Let me know if you have any thoughts - unless you say otherwise, I'll try to fix the borderRect_ rendering (but make it invisible) to see if it fixes the alignment as well as this.

@rachel-fenichel
Copy link
Collaborator

iirc vertical rendering is broken in a fairly trivial way (something is
undefined and that's making svg sad).

On Wed, Mar 30, 2016 at 8:44 AM Rodrigo Queiro [email protected]
wrote:

Is there a way I can test the vertical rendering at the moment? If I open
vertical_playground.html I get broken blocks:

[image: broken vertical rendering]
https://cloud.githubusercontent.com/assets/632207/14146781/2956ce62-f699-11e5-988b-a30a97e18860.png

I've looked into the borderRect_ option, which is a little weird. The
image below shows a classic Blockly block - the borderRect_ is the lighter
green background for the text, which also provides a nice click target. Its
width is calculated by Field.render_ (never called as the horizontal
rendered doesn't call field.getSize()) to give SEP_SPACE_X/2 margin either
side of the text.

[image: blockly classic]
https://cloud.githubusercontent.com/assets/632207/14147924/bb823d40-f69d-11e5-81e8-9df3f18fcc2f.png

As FieldTextInput.resizeEditor_() uses the borderRect_ size (from
Field.getAbsoluteXY_()) to determine how to size the , this bug means that
the text doesn't quite line up when editing, so I think fixing the
borderRect_ rendering is worth it regardless. Doing this will increase the
size of the click target, although it won't quite fill the shadow block.

To make the whole shadow block active, I think we'd need to install the
handler differently in horizontal/vertical rendering, although I don't have
a feeling for how vertical rendering is meant to work.

Let me know if you have any thoughts - unless you say otherwise, I'll try
to fix the borderRect_ rendering (but make it invisible) to see if it fixes
the alignment as well as this.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#132 (comment)

drigz referenced this issue in drigz/scratch-blocks-old Mar 31, 2016
If a block only has one field, the mouseup event (which triggers editing
of editable fields) will be bound to the block instead of the field.

Fixes #132.
@drigz
Copy link
Collaborator Author

drigz commented Mar 31, 2016

I've gone for the first approach, with a check that the block only has one field (true for these shadow blocks and a few others). Given the change from using Field.borderRect_ as a text background to using only BlockSvg.svgPath_, this makes sense to me. Do you think this will cause an issue with vertical rendering?

As a side-note, it seems like borderRect_ is now only used by the subclasses of Field via Field.getAbsoluteXY_ and Field.getScaledBBox_ in order to position their editors over the field. Are you planning on restoring the concept of a field that implements its own chrome, or are you going to use shadow blocks for all fields? I quite like the latter idea, as it can be very hard to decide if you want a field or an inline input.

If fields don't need their own chrome, removing Field.borderRect_ might make the layout code simpler and more direct.

@RoboErikG
Copy link
Contributor

Another approach would be to make shadow blocks transparently wrap their field (height and width are height and width of their only field and they don't draw anything) and style the field to draw the oval..

@tmickel
Copy link
Contributor

tmickel commented Apr 1, 2016

@drigz By the way, not sure about this, we should discuss. Having the block render the chrome is nice also because we will usually render fields differently in horizontal vs. vertical...

So I would lean toward rendering the fields in the appropriate block rendering code.

@drigz drigz closed this as completed in #155 Apr 4, 2016
drigz added a commit that referenced this issue Apr 4, 2016
Increase active area on one-field-blocks #132
github-actions bot pushed a commit that referenced this issue Oct 18, 2024
# [1.2.0-beta.1](v1.1.86...v1.2.0-beta.1) (2024-10-18)

### Bug Fixes

* Add support for flyout labels with status indicators ([#212](#212)) ([665d196](665d196))
* add support for Scratch-style block comments ([#83](#83)) ([8902091](8902091))
* add support for Scratch-style procedures ([#39](#39)) ([13647eb](13647eb))
* add zoom controls config ([#126](#126)) ([a09ae24](a09ae24))
* allow focusing fields in the flyout on mobile ([#184](#184)) ([6c9d3a6](6c9d3a6))
* allow specifying the function to be used for prompting about variable creation/edits ([#106](#106)) ([4cfe66f](4cfe66f))
* clean up data block definitions ([#90](#90)) ([9ea96e2](9ea96e2))
* correctly align extension block icons ([#182](#182)) ([e3dbad1](e3dbad1))
* delete context menu to display the correct number of blocks ([#127](#127)) ([a65d24a](a65d24a))
* **deps:** after installing deps, replace Blockly v11 with v12 RC ([677ff6f](677ff6f))
* **deps:** clone Blockly RC over HTTP instead of SSH ([8a861f0](8a861f0))
* display icons in the toolbox for extension categories ([#47](#47)) ([b53eadd](b53eadd))
* don't hide the drag surface ([#38](#38)) ([7f70f09](7f70f09))
* don't show global/local options when renaming a variable ([#123](#123)) ([22a6b73](22a6b73))
* don't show scope options when renaming a variable from the variable getter context menu ([#139](#139)) ([375e56d](375e56d))
* don't warn about procedure references when moving the definition on the workspace ([#131](#131)) ([cda58cc](cda58cc))
* enable and style workspace comments ([#82](#82)) ([98ccb62](98ccb62))
* enable dragging arguments out of procedure blocks ([#119](#119)) ([0ca0620](0ca0620))
* Export colours. ([7c346fa](7c346fa))
* Export Scratch messages. ([09326a1](09326a1))
* fix a crash when adding a broadcast message ([#150](#150)) ([8e165ce](8e165ce))
* fix alignment of "define" text baseline on custom blocks ([#220](#220)) ([cc4d9f9](cc4d9f9))
* fix bug that caused the number/string input in the custom block editor to have square corners ([#213](#213)) ([c3ee958](c3ee958))
* fix bug that could cause duplicated procedure argument blocks to create more duplicates on drag ([#217](#217)) ([6a1c8a9](6a1c8a9))
* fix bug that prevented modal dialogs from appearing on mobile ([#183](#183)) ([37e0f10](37e0f10))
* fix bug that prevented showing the contextual menu on blocks ([#176](#176)) ([2e98ff1](2e98ff1))
* fix color of block reporter dropdown text ([#205](#205)) ([73d978e](73d978e))
* fix dropdown menu metrics ([#148](#148)) ([40eee91](40eee91))
* fix exception when editing custom blocks ([#105](#105)) ([7478546](7478546))
* fix positioning of categories when scrolling via the toolbox ([#186](#186)) ([6d14530](6d14530))
* fix styling of dropdown menus ([#152](#152)) ([0e80277](0e80277))
* fix the color of procedure argument blocks ([#216](#216)) ([88c700e](88c700e))
* fix the colors of the angle picker dropdown ([#179](#179)) ([59896d2](59896d2))
* fix the flyout width at 250 pixels ([#168](#168)) ([a47aba6](a47aba6))
* fix the styling of contextual menus ([#147](#147)) ([6fbc2e5](6fbc2e5))
* fix toolbox category selection ([#141](#141)) ([d3e1a1b](d3e1a1b))
* fix wrapping of long category labels ([#166](#166)) ([7b39ac1](7b39ac1))
* fixed bug where broadcast messages would appear in the variable dropdown list ([#124](#124)) ([b1e67f6](b1e67f6))
* improve positioning of newly created procedure blocks ([#121](#121)) ([84a9e5b](84a9e5b))
* improve reliability of block value reporting ([#77](#77)) ([cb5b068](cb5b068))
* improve sizing and rendering of comments ([#219](#219)) ([1279c0a](1279c0a))
* load CSS and fix up UI appearance ([#33](#33)) ([1645129](1645129))
* load the continuous toolbox ([#31](#31)) ([ea68b1c](ea68b1c))
* make block images work in all contexts ([#30](#30)) ([920febf](920febf))
* make FieldNumber a subclass of FieldTextInput ([#214](#214)) ([3ae2235](3ae2235))
* make variable names case-sensitive ([#122](#122)) ([46854cd](46854cd))
* match Scratch behaviors around dragging and connection stickiness ([#80](#80)) ([fd1bc58](fd1bc58))
* miscellaneous UI fixits ([#41](#41)) ([300a1ce](300a1ce))
* modernize and reenable the colour slider field ([#42](#42)) ([4f97982](4f97982))
* more closely align flyout layout with Scratch ([#45](#45)) ([49663ed](49663ed))
* prevent deleting procedure definition blocks with references by dragging to the flyout ([#120](#120)) ([fa9367d](fa9367d))
* prevent dragging blocks into the slot occupied by the procedure definition block's example caller block ([#118](#118)) ([453ffa9](453ffa9))
* re-export scratch-blocks utility functions ([#26](#26)) ([685ecfc](685ecfc))
* readd the control blocks ([#22](#22)) ([f69d4ac](f69d4ac))
* readd the data blocks ([#29](#29)) ([fafed65](fafed65))
* readd the event blocks ([#21](#21)) ([4de530f](4de530f))
* readd the looks blocks ([#23](#23)) ([34f07c0](34f07c0))
* readd the motion blocks ([#20](#20)) ([79398c2](79398c2))
* readd the operator blocks and dependencies ([#19](#19)) ([8024e9f](8024e9f))
* readd the sensing blocks ([#27](#27)) ([9f5f135](9f5f135))
* readd the sound blocks ([#24](#24)) ([6837513](6837513))
* reenable reporting block values ([#55](#55)) ([70c8cfd](70c8cfd))
* reenable shadows for blocks being dragged ([#79](#79)) ([94d2a2c](94d2a2c))
* reenable support for checkboxes in the flyout ([#43](#43)) ([e603c67](e603c67))
* reenable support for dragging blocks between sprites ([#130](#130)) ([3d8b998](3d8b998))
* reenable the matrix field ([#49](#49)) ([aa3341b](aa3341b))
* reenable the mobile numpad field ([#54](#54)) ([003afd0](003afd0))
* reenable the note block and picker field ([#48](#48)) ([de62d77](de62d77))
* reenable the vertical separator field ([#46](#46)) ([48e931f](48e931f))
* remove canvas transition ([#129](#129)) ([ff4b115](ff4b115))
* remove underscore from a few createProcedureDefCallback calls ([#40](#40)) ([4e794f6](4e794f6))
* render the procedure definition block like Scratch ([#115](#115)) ([2a543f5](2a543f5))
* resolve error when adding the stop block to the workspace ([#56](#56)) ([f3e059c](f3e059c))
* resolve various UI issues ([#117](#117)) ([4b74d5c](4b74d5c))
* select new variable blocks' monitor checkboxes after creation ([#140](#140)) ([3811d93](3811d93))
* show connection highlights for boolean inputs ([#181](#181)) ([303611a](303611a))
* show the glow only when blocks are running ([#57](#57)) ([33e9e91](33e9e91))
* show the name of the list in the list getter block context menu ([#132](#132)) ([eb839fc](eb839fc))
* update the flyout for compatibility with the new flyout API ([#209](#209)) ([7ce9991](7ce9991))
* use non-deprecated input type constants ([#78](#78)) ([1f1c859](1f1c859))
* use Scratch-style text blocks ([#37](#37)) ([6bbbdf7](6bbbdf7))
* use Scratch's FieldAngle ([#138](#138)) ([ef7911c](ef7911c))

### Features

* add a block inflater that supports recycling ([#207](#207)) ([0701679](0701679))
* add bubbles/icons for block flyout checkboxes ([#208](#208)) ([39b2162](39b2162))
* add custom Scratch variable model and creation event classes ([#86](#86)) ([2598ede](2598ede))
* clean up and export Scratch's variables.js ([#88](#88)) ([5c1acfe](5c1acfe))
* readd support for the custom Data toolbox category ([#87](#87)) ([dcfbf39](dcfbf39))
* reenable Scratch's FieldVariable subclass ([#91](#91)) ([7c891e3](7c891e3))

### Reverts

* Revert "fix: add zoom controls config (#126)" (#128) ([8e1dc14](8e1dc14)), closes [#126](#126) [#128](#128)
github-actions bot pushed a commit that referenced this issue Oct 21, 2024
# [2.0.0-spork.1](v1.1.86...v2.0.0-spork.1) (2024-10-21)

### Bug Fixes

* Add support for flyout labels with status indicators ([#212](#212)) ([665d196](665d196))
* add support for Scratch-style block comments ([#83](#83)) ([8902091](8902091))
* add support for Scratch-style procedures ([#39](#39)) ([13647eb](13647eb))
* add zoom controls config ([#126](#126)) ([a09ae24](a09ae24))
* allow focusing fields in the flyout on mobile ([#184](#184)) ([6c9d3a6](6c9d3a6))
* allow specifying the function to be used for prompting about variable creation/edits ([#106](#106)) ([4cfe66f](4cfe66f))
* clean up data block definitions ([#90](#90)) ([9ea96e2](9ea96e2))
* correctly align extension block icons ([#182](#182)) ([e3dbad1](e3dbad1))
* delete context menu to display the correct number of blocks ([#127](#127)) ([a65d24a](a65d24a))
* **deps:** after installing deps, replace Blockly v11 with v12 RC ([677ff6f](677ff6f))
* **deps:** clone Blockly RC over HTTP instead of SSH ([8a861f0](8a861f0))
* display icons in the toolbox for extension categories ([#47](#47)) ([b53eadd](b53eadd))
* don't hide the drag surface ([#38](#38)) ([7f70f09](7f70f09))
* don't include Blockly RC source in npm package ([21b15d1](21b15d1))
* don't show global/local options when renaming a variable ([#123](#123)) ([22a6b73](22a6b73))
* don't show scope options when renaming a variable from the variable getter context menu ([#139](#139)) ([375e56d](375e56d))
* don't warn about procedure references when moving the definition on the workspace ([#131](#131)) ([cda58cc](cda58cc))
* enable and style workspace comments ([#82](#82)) ([98ccb62](98ccb62))
* enable dragging arguments out of procedure blocks ([#119](#119)) ([0ca0620](0ca0620))
* Export colours. ([7c346fa](7c346fa))
* Export Scratch messages. ([09326a1](09326a1))
* fix a crash when adding a broadcast message ([#150](#150)) ([8e165ce](8e165ce))
* fix alignment of "define" text baseline on custom blocks ([#220](#220)) ([cc4d9f9](cc4d9f9))
* fix bug that caused the number/string input in the custom block editor to have square corners ([#213](#213)) ([c3ee958](c3ee958))
* fix bug that could cause duplicated procedure argument blocks to create more duplicates on drag ([#217](#217)) ([6a1c8a9](6a1c8a9))
* fix bug that prevented modal dialogs from appearing on mobile ([#183](#183)) ([37e0f10](37e0f10))
* fix bug that prevented showing the contextual menu on blocks ([#176](#176)) ([2e98ff1](2e98ff1))
* fix color of block reporter dropdown text ([#205](#205)) ([73d978e](73d978e))
* fix dropdown menu metrics ([#148](#148)) ([40eee91](40eee91))
* fix exception when editing custom blocks ([#105](#105)) ([7478546](7478546))
* fix positioning of categories when scrolling via the toolbox ([#186](#186)) ([6d14530](6d14530))
* fix styling of dropdown menus ([#152](#152)) ([0e80277](0e80277))
* fix the color of procedure argument blocks ([#216](#216)) ([88c700e](88c700e))
* fix the colors of the angle picker dropdown ([#179](#179)) ([59896d2](59896d2))
* fix the flyout width at 250 pixels ([#168](#168)) ([a47aba6](a47aba6))
* fix the styling of contextual menus ([#147](#147)) ([6fbc2e5](6fbc2e5))
* fix toolbox category selection ([#141](#141)) ([d3e1a1b](d3e1a1b))
* fix wrapping of long category labels ([#166](#166)) ([7b39ac1](7b39ac1))
* fixed bug where broadcast messages would appear in the variable dropdown list ([#124](#124)) ([b1e67f6](b1e67f6))
* hide disable and inline inputs contextual menu items ([#35](#35)) ([c548298](c548298))
* improve positioning of newly created procedure blocks ([#121](#121)) ([84a9e5b](84a9e5b))
* improve reliability of block value reporting ([#77](#77)) ([cb5b068](cb5b068))
* improve sizing and rendering of comments ([#219](#219)) ([1279c0a](1279c0a))
* load CSS and fix up UI appearance ([#33](#33)) ([1645129](1645129))
* load the continuous toolbox ([#31](#31)) ([ea68b1c](ea68b1c))
* make block images work in all contexts ([#30](#30)) ([920febf](920febf))
* make FieldNumber a subclass of FieldTextInput ([#214](#214)) ([3ae2235](3ae2235))
* make variable names case-sensitive ([#122](#122)) ([46854cd](46854cd))
* match Scratch behaviors around dragging and connection stickiness ([#80](#80)) ([fd1bc58](fd1bc58))
* miscellaneous UI fixits ([#41](#41)) ([300a1ce](300a1ce))
* modernize and reenable the colour slider field ([#42](#42)) ([4f97982](4f97982))
* more closely align flyout layout with Scratch ([#45](#45)) ([49663ed](49663ed))
* prevent deleting procedure definition blocks with references by dragging to the flyout ([#120](#120)) ([fa9367d](fa9367d))
* prevent dragging blocks into the slot occupied by the procedure definition block's example caller block ([#118](#118)) ([453ffa9](453ffa9))
* re-export scratch-blocks utility functions ([#26](#26)) ([685ecfc](685ecfc))
* readd the control blocks ([#22](#22)) ([f69d4ac](f69d4ac))
* readd the data blocks ([#29](#29)) ([fafed65](fafed65))
* readd the event blocks ([#21](#21)) ([4de530f](4de530f))
* readd the looks blocks ([#23](#23)) ([34f07c0](34f07c0))
* readd the motion blocks ([#20](#20)) ([79398c2](79398c2))
* readd the operator blocks and dependencies ([#19](#19)) ([8024e9f](8024e9f))
* readd the sensing blocks ([#27](#27)) ([9f5f135](9f5f135))
* readd the sound blocks ([#24](#24)) ([6837513](6837513))
* reenable reporting block values ([#55](#55)) ([70c8cfd](70c8cfd))
* reenable shadows for blocks being dragged ([#79](#79)) ([94d2a2c](94d2a2c))
* reenable support for checkboxes in the flyout ([#43](#43)) ([e603c67](e603c67))
* reenable support for dragging blocks between sprites ([#130](#130)) ([3d8b998](3d8b998))
* reenable the matrix field ([#49](#49)) ([aa3341b](aa3341b))
* reenable the mobile numpad field ([#54](#54)) ([003afd0](003afd0))
* reenable the note block and picker field ([#48](#48)) ([de62d77](de62d77))
* reenable the vertical separator field ([#46](#46)) ([48e931f](48e931f))
* remove canvas transition ([#129](#129)) ([ff4b115](ff4b115))
* remove underscore from a few createProcedureDefCallback calls ([#40](#40)) ([4e794f6](4e794f6))
* render the procedure definition block like Scratch ([#115](#115)) ([2a543f5](2a543f5))
* resolve error when adding the stop block to the workspace ([#56](#56)) ([f3e059c](f3e059c))
* resolve various UI issues ([#117](#117)) ([4b74d5c](4b74d5c))
* select new variable blocks' monitor checkboxes after creation ([#140](#140)) ([3811d93](3811d93))
* show connection highlights for boolean inputs ([#181](#181)) ([303611a](303611a))
* show the glow only when blocks are running ([#57](#57)) ([33e9e91](33e9e91))
* show the name of the list in the list getter block context menu ([#132](#132)) ([eb839fc](eb839fc))
* update the flyout for compatibility with the new flyout API ([#209](#209)) ([7ce9991](7ce9991))
* use non-deprecated input type constants ([#78](#78)) ([1f1c859](1f1c859))
* use Scratch-style text blocks ([#37](#37)) ([6bbbdf7](6bbbdf7))
* use Scratch's FieldAngle ([#138](#138)) ([ef7911c](ef7911c))

* fix!: bump to v2.0 to reflect Blockly un-forking ([899a981](899a981))

### Features

* add a block inflater that supports recycling ([#207](#207)) ([0701679](0701679))
* add bubbles/icons for block flyout checkboxes ([#208](#208)) ([39b2162](39b2162))
* add custom Scratch variable model and creation event classes ([#86](#86)) ([2598ede](2598ede))
* clean up and export Scratch's variables.js ([#88](#88)) ([5c1acfe](5c1acfe))
* readd support for the custom Data toolbox category ([#87](#87)) ([dcfbf39](dcfbf39))
* reenable Scratch's FieldVariable subclass ([#91](#91)) ([7c891e3](7c891e3))

### Reverts

* Revert "fix: add zoom controls config (#126)" (#128) ([8e1dc14](8e1dc14)), closes [#126](#126) [#128](#128)

### BREAKING CHANGES

* scratch-blocks is no longer a divergent fork of
Blockly, and instead depends on Blockly as a regular node_modules
dependency.

Thanks, @gonfunko and everyone else at Google who helped with this
effort!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants