I have noticed if I make window’s height very tall so there is a scroll bar on the right when a user uses the mouse wheel to scroll the scroll bar barely moves. Is there a way to speed up the mouse wheel scroll on tall windows?
Thank you,
I have noticed if I make window’s height very tall so there is a scroll bar on the right when a user uses the mouse wheel to scroll the scroll bar barely moves. Is there a way to speed up the mouse wheel scroll on tall windows?
Thank you,
You can change the mouse wheel settings within your OS, but that will affect other programs (like a browser). If you like, I can move this over to the feature request section, and perhaps it can be implemented by:
how about a setting that can be changed with code so I can figure out the window height and adjust the setting for each window for the amount of lines/pixels per notch?
Try JScrollBar#setUnitIncrement(int)
You can get the JScrollBar from a JScrollPane using JScrollPane#getVerticalScrollBar()
cool I just put this in the internalFrameOpened on my startup window and it seems to make the scroll wheel much better for all my windows.
#increases scroll bar speed
from javax.swing import SwingUtilities
from javax.swing import JScrollPane
scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source)
scrollPane.getVerticalScrollBar().setUnitIncrement(10)
Hello,
I’m asking if we could do the same with the scroll bar from a Template Repeater component ?
It would be very useful, and it is working for me and window scroll bar.
Template Repeater
from javax.swing import SwingUtilities
from javax.swing import JScrollPane
scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Repeater').getComponents()[1].getComponents()[2])
scrollPane.getVerticalScrollBar().setUnitIncrement(30) #scroll amount for wheel and arrows
scrollPane.getVerticalScrollBar().setBlockIncrement(30) #scroll amount clicking on scrollbar itself
Template Canvas
from javax.swing import SwingUtilities
from javax.swing import JScrollPane
scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Canvas').getComponents()[2].getComponents()[0])
scrollPane.getVerticalScrollBar().setUnitIncrement(30) #scroll amount for wheel and arrows
scrollPane.getVerticalScrollBar().setBlockIncrement(30) #scroll amount clicking on scrollbar itself
Can you explain me this part:
"
event.source.parent.getComponent(‘Template Repeater’).getComponents()[1].getComponents()[2])
"
Because i got this error:
Traceback (most recent call last):
File “event:visionWindowOpened”, line 6, in
TypeError: getComponent(): 1st arg can’t be coerced to int
Did you copy the script directly?
In Jae’s example, he’s using component.getComponents()
(note the plural), while the error you copied has getComponent()
singular.
Yes, i copied directly from your example.
but still have this error:
Traceback (most recent call last):
File "event:visionWindowOpened", line 4, in
TypeError: getComponent(): 1st arg can't be coerced to int
Ignition v7.9.4-beta1 (b2017061413)
Java: Oracle Corporation 1.8.0_131
Executed script on window event: visionWindow.visionWindowOpened:
from javax.swing import SwingUtilities
from javax.swing import JScrollPane
scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane,SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Repeater').getComponents()[1].getComponents()[2]))
scrollPane.getVerticalScrollBar().setUnitIncrement(30) #scroll amount for wheel and arrows
scrollPane.getVerticalScrollBar().setBlockIncrement(30) #scroll amount clicking on scrollbar itself
Ah. You can’t run these on a visionWindowOpened as is; when they step out to ‘event.source.parent’ they’re going outside of the typical Ignition boundaries. I’m not sure this will still work directly, but try replacing the scrollPane =
line with this:
scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane,SwingUtilities.getAncestorOfClass(JScrollPane, event.source.rootContainer.getComponent('Template Repeater').getComponents()[1].getComponents()[2]))
I cannot use the new line of code of the scrollPane in the visionWindowOpened it seems to have no error but my scrollbar stay with the same speed.
I move the code inside the Template Repeater on propertyChange event and it is working great now.
Sorry to revive such an old post, and apologies for the potentially obvious question… (I’m very new to Java)
When using getComponents(), what’s the reason for using the getAncestorOfClass function?
I noticed that the object returned from:
scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent('Template Repeater').getComponents()[1].getComponents()[2])
is exactly the same as the object returned from simply:
scrollPane = event.source.parent.getComponent('Template Repeater').getComponents()[1]
If the whole process of getting the scroll pane object was dynamic, I would understand this, however both the indexes of the getComponents() collection are hardcoded, so I don’t understand why the getting of the JScrollPane object should be made dynamic?
Is there any way do achieve the same thing but fully dynamically without hardcoding the indexes?
Thanks in advance!
Nick