Avoid vaadin grid automatic horizontal scroll after click - java

I'm using vaadin 8.1 in my project.
I needed to give an extra large width to a grid column (the latest at the right), and when user clicks in one field of this extra large column, vaadin move horizontal scroll automatically at the end of the grid. I would like stop this vaadin behaviour. I researched and I tried different things but I didn't find anything,
How can I do it?
Thank you,
Best regards

There is no API in Vaadin to turn it off (You can find feature request here: https://github.com/vaadin/framework/issues/7667). There is one trick you could try, namely disable pointer events in Grid cells. It is a bit harsh method, since it will disable also selection and item click.
In your code
grid.setStyleGenerator(item -> { return "disable-events";});
And your theme
.disable-events {
pointer-events: none;
}
It is possible to add the style generator also for one Column only, which could be option to you as well

Related

Libgdx - Remove HTML greybackground/recompile button/ load splash

What is the proper way to remove the grey background that covers the entire screen, the recompile button, and the default libGDX load and/or load splash in a HTML build of my game?
Note: This answer applies only to the gdx-setup tool as of late 2022. The gdx-liftoff tool is similar but has a slightly less boneheaded configuration out of the box. Additionally, I would like to get some of libGDX's HTML backend reworked one day, as there is no point in the padding and it's applied unevenly, plus less obvious things like the way it creates a table for layout.
Grey background
The background colour can be customised by changing background: #222222 in html/webapp/styles.css to some other colour. Or apply it directly to the body in index.html and delete styles.css (plus the link to it) as it doesn't contain anything important once the superdev button has been removed.
Grey border
The border around the game can be removed by editing HtmlLauncher like so:
#Override
public GwtApplicationConfiguration getConfig () {
GwtApplicationConfiguration config = new GwtApplicationConfiguration(true);
config.padHorizontal = 0;
config.padVertical = 0;
return config;
}
Separating GwtApplicationConfiguration into a config variable brings it in line with the other launchers (desktop, Android, iOS) and setting the padding to 0 is self-explanatory. While we're here, passing true into the app config's constructor tells it to render at native resolution on high-DPI/"retina" displays instead of upscaling.
Recompile button
Or the superdev button, as I call it. Just remove the <a class="superdev"... line from html/webapp/index.html. If you need access to it during development, it's recommended you add its link to your bookmark bar. Visibility of the bookmark bar can be toggled using Ctrl+Shift+B in Chrome and Firefox.
Load/splash screen
You're probably best referring to https://libgdx.com/wiki/html5-backend-and-gwt-specifics#changing-the-load-screen-progress-bar for this (which may not have existed when the question was asked). In short, getPreloaderCallback() and adjustMeterPanel() can be overridden in HtmlLauncher. I typically just overwrite logo.png after building instead of using the recommended method for changing the logo.
Other changes
Things you might want to change before a final release:
styles.css isn't very important beyond changing the background colour, as noted earlier.
In index.html, a comma should be added to between device-width and initial-scale for it to be valid HTML.
In index.html, applying align="center" to a div is deprecated behaviour. Probably best remove that alignment. If you need it, apply via CSS instead.
In index.html, handleMouseDown() and handleMouseUp() are completely pointless, as far as I can see. I don't use them for my own projects and have had no complaints.
html/build/dist/assets/assets.txt references some files that may not be necessary. The default font (arial or lsans, depending on libGDX version) is only needed if you use it and the vertex/fragment shaders are only needed if you do 3D stuff, I believe. Removing these can remove load times ever so slightly, especially on HTTP/1.1 connections. But I don't have an automated way to remove those lines (except on Linux - head -n -8).
Setting an asset filter as seen at https://libgdx.com/wiki/html5-backend-and-gwt-specifics#speeding-up-preload-process is an easy way to reduce your load times. I return false for music files to reduce load times greatly - it ends up streaming music instead of preloading it (if using Music, not AssetManager).

JavaFX ComboBox shows scrollbars on first click

I'm doing a program in JavaFX with ComboBoxes, and loading a FXML for the layout.
When I click for the first time in a ComboBox with few items (only two, for example), the scrollbar is shown at the right side. After I open it again, the scrollbar doesn't appear anymore.
I tried some solutions. One that worked is to apply a CSS directly in the FXML, which sets the cell size to a fixed value. But a solution inside the code (for example, in the initialize function in the controller) would be better for my case.
Thanks for any help.
This problem seems to be fixed in recent JDK versions, see https://bugs.openjdk.java.net/browse/JDK-8095019
If the options would stay fixed I would suggest using ChoiceBox instead of ComboBox. It is basically the same, but without the scrollable option. If you insist using ComboBox you can try combobox.setVisibleRowCount()

Formatting JEditorPane's cursor, tooltips, links

Right now, I'm using Java Swing to create a JEditorPane primarily for its ability to have hyperlinks. I've successfully been able to display links and have them execute behavior upon a click, but I'm running into a few problems with formatting.
How can I set the cursor so that it normally is an arrow, but changes to a text cursor when hovering over text? (In essence, the behavior a cursor has within a web browser). I tried
EditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR))
but that made it a text cursor everywhere, even when not hovering over text. Right now, hovering over a link shows a pointer hand; I'd like to maintain that functionality as well.
What is the best way to show tooltips or mouseover text when hovering over a link? I tried modifying the title attribute of the link but nothing showed up.
I was trying to implement links to skip down to a subsection of the page, much like http://en.wikipedia.org/wiki/Xkcd#History would take you directly to the History subsection of Wikipedia's xkcd page. How can I do this?
An answer to any of these would be great (and multiple would be awesome xP). Thanks a lot for your help!
As you said one can simply give answers to a single point as well, let me try one by one, here is the answer for your last Point 3
Just provide an id to your tag like this
<h1><a id = "top"></a>First Line</h1>
Now somewhere in the bottom of your page write this :
<p>Return to TOP</p>
Clicking this link, you will reach the above area of the PAGE.
Points 1 & 2 may be addressed using the approach mentioned here. In particular, the view/model conversion methods will let you condition setCursor() and getToolTipText(), respectively.
You can get source from here http://java-sl.com/JEditorPaneStructureTool.html
It shows how to obtain text view bounds. First you get caret position for current mouse poiunter using viewToModel() method. Then go down the Views tree achieving leaf view and calcualte it's bounds. See this http://java-sl.com/tip_view_rectangle.html
If your mouse pointer in the view's rectangle then your mouse over text.
You can check whether the text in caret position is link and show your tooltip.
Use this http://java-sl.com/tip_links_in_editable.html to see how to detect whether mouse is over link.
Point 3.rd is answered by #nIcE cOw

Listfield focus issue in blackberry

I am using list-field in a BlackBerry application. In each list-field item, I have a bitmap-field at the left, text at center and again a bitmap-field at the right.
Can I determine whether the fields are focusable inside the list-field rows for keypad versions of BlackBerry Devices for e.g BlackBery Tour?
No in list field no control except whole row is focusable explicitly. If you want to perform any click events you can use touchEvent() but the calculation will be too complex and not so reliable.
If you want to have separate clickable items in one row you must use HorizontalFieldManager each time.
Update: : I have come across this scenario twice, and if I were in place of you I will consider what exactly the feature is about, If you are concerned about UI and there is not any heavy functionality behind focusing you can try touchEvent or navigationClick but using both will be cumbersome. Too much logic, too much thinking, hard to test.
If there is any functionality, you have an option to add them on menu, It will be more convenient way than using horizontal field manager or the above mentioned methods.

Changing the direction of a Combo box dropdown in SWT

I'm building an Eclipse plugin in SWT, and I have the following problem: one of my fields is a combo box, and in some cases it may have fairly long items as selection options. My plugin runs on the right side of the screen, so when you go to use the combo-box, the right side of the combo box is cut off. So, my question is: is there any way to change the dropdown's alignment relative to the combo control? It seems to be permanently left-aligned... and I'm pretty sure you can change the direction in Swing (though the only place I've seen it done is in the Substance UI demo. The Combo Box tab has boxes with North, South East, and West flyout directions... for my application, I need something like the West flyout)
Note: Setting actual text limits is a last-case-scenario option; it would be quite a bit of guesswork to set the text limit dynamically (since the widget's view can be resized).
Here's a picture (sorry, I can only have one link and no images :( ... I need some more rep :p)
Left side of the line: Proper width - the view is the wide enough for the combo dropdown to display all the text; you can see the scrollbars on the right side.
Right side of the line: Too small - Here, the view has been resized, and the combo dropdown scrollbar (as well as some of the text) is cut off by the right side of the screen. I always have more screen space available to the left (since this is always on the right hand side of the screen), but the combo dropdown always appears to the lower right.
Hopefully this is clear enough.
Now I understand your problem.
Use a CCombo instead of a Combo. It should automatically position the drop-down list so it fits.
Hi I came across the same problem. CCombo does the trick but it doesnt look good and it has bug like this one that wont be fixed.
combo.setOrientation(SWT.RIGHT_TO_LEFT); does the trick for you.

Categories

Resources