I was playing around with ScrollPane options in order to disable the wheel scroll functionality of the vertical bar. Tried myScrollPane.mouseEnabled = false;, myScrollPane.mouseWheelEnabled = false; with no luck. Also, myScrollPane.verticalLineScrollSize = 0; also did not seem to result in desired effect.
Okkkk this should be what you're looking for!
myScrollPane.addEventListener(MouseEvent.MOUSE_WHEEL, disableScroll, true);
function disableScroll(e:MouseEvent):void
{
e.stopPropagation();
}
Related
I'm looking for a way in ActionScript 3 to allow the user to scroll a TextField (left to right) if the amount of text is greater than the TextField's width without the cursor changing to the flashing I.
The textfield is inside a MovieClip. I cannot use MouseChildren = false and selectable = false as both stop the textfield being scrollable.
Any ideas?
Well, the simplest way is to set the myTextField.selectable = false. The cursor doesn't change and the text field's content remains scrollable. Maybe I missed something here, but it works on my simple test.
If you're still open to suggestions...
(This is roll-over scrolling instead of mouse-down to scroll by dragging)
var scrollSize : int = 5; //# scrolling speed
tf.selectable = false;
tf.height = 25; //# (set height only if [tf] is already on Stage with text)
tf.addEventListener(MouseEvent.MOUSE_OVER, scroll_start);
tf.addEventListener(MouseEvent.MOUSE_OUT, scroll_stop);
function scroll_start (evt:MouseEvent) : void
{ tf.addEventListener(Event.ENTER_FRAME, handler_enterFrame ); }
function scroll_stop (evt:MouseEvent) : void
{ tf.removeEventListener(Event.ENTER_FRAME, handler_enterFrame ); }
function handler_enterFrame (evt:Event) : void
{
//# touch right edge = scroll text towards left
if ( tf.mouseX >= (tf.width - 10) ) { tf.scrollH += scrollSize; }
//# touch left edge = scroll text towards right
if ( tf.mouseX <= (tf.x + 10) )
{
if ( tf.scrollH > 0 ){ tf.scrollH -= scrollSize; }
else { /* do else here = Hurray */ }
}
}
There is a weird effect that only happens if you scroll fully to the end of text/sentence and then immediately scroll backwards, when it reaches zero scroll there is a "bounce" effect. Likely caused by Enter Frame event. Will check that later tonight if possible but the general concept is there in code...
Gotta fly but hope it helps...
I'd suggest the following:
switch off mouse interactivity for the child TextField
mc.mouseChildren = false;
mc.addEventListener(MouseEvent.MOUSE_WHEEL, scroll);
and scroll it manually:
private function scroll(e:MouseEvent):void{
tf.scrollV += e.delta;
}
Working example here
update:
To scroll text horizontally you need to change the scrollH property of the TextField, for example you may handle MOUSE_WHEEL event like this:
private function scroll(e:MouseEvent):void{
tf.scrollH -= e.delta;
}
I'm using a Custom Cursor when hovering a movieclip by using MOUSE_MOVE
spectrum.addEventListener(MouseEvent.MOUSE_MOVE,function(e:MouseEvent):void{
Mouse.hide();
mouseCursor.visible = true;
mouseCursor.startDrag(true);
mouseCursor.mouseEnabled = false;
mouseCursor.mouseChildren = false;
e.updateAfterEvent();
});
when I set
wmode='transparent'
MOUSE_MOVE still works smoothly on Chrome and IE, but on FireFox the cursor becomes super laggy when hovering the MovieClip..any ideas why?
I also tried EnterFRAME with the Custom Cursor, but it's also laggy..
If I set wmode ='window' MOUSE_MOVE works again, and not laggy anymore..
Why does mousemove become so laggy when setting wmode='transparent' on FireFox ? Can anyone help me ?
I'm not sure that your problem is wmode = transparent!
Rather than constantly starting the drag, you should rather either just start it once and then stop it when you dont need it anymore
or
just set the cursors position rather than using drag.
spectrum.addEventListener(MouseEvent.MOUSE_MOVE,function(e:MouseEvent):void{
Mouse.hide();
mouseCursor.visible = true;
mouseCursor.mouseEnabled = false;
mouseCursor.mouseChildren = false;
mouseCursor.x = mouseX;
mouseCursor.y = mouseY;
});
I have created a ScrollPane but there is no bar to scroll with (like the one on the side of your browser) you have to drag with your mouse. How can I get a scroll bar?
What I did to add a scrollbar was use libgdx's ScrollPane.ScrollPaneStyle to set the scroll bar as a ninepatch.
ScrollPane.ScrollPaneStyle scrollStyle;
/...
scrollTexture = new Texture(Gdx.files.internal("Scroll9.png"));
scrollNine = new NinePatch(new TextureRegion(scrollTexture,6,6),2,2,2,2);
then I created the vertical scroll knob
scrollStyle = new ScrollPane.ScrollPaneStyle();
scrollStyle.vScrollKnob = new NinePatchDrawable(box);
and applied the style to my scrollable table
scroll = new ScrollPane(test, scrollStyle);
source:
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.ScrollPaneStyle.html
The bar is enabled via the skin:
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
ScrollPane scrollPane=new ScrollPane(resultsTextArea, skin);
I tried. It works now...
This is untested!
It seems that using the following enables scrollbars for a scrollpane.
boolean enable_x = true;
boolean enable_y = true;
scrollpane.setForceScroll(enable_x,enable_y);
source: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html
In my application i have a mouse cursor which is attached to the mouse. However it will not let me click on buttons within my application which is a big problem for me as buttons are essential in what i need to do.
I am new to AS so any help would be much appreciated!
stage.addEventListener(MouseEvent.MOUSE_MOVE, draw_cursor);
stage.addEventListener(Event.MOUSE_LEAVE, hide_cursor);
Mouse.hide();
function draw_cursor(event:MouseEvent):void
{
my_cursor_mc.visible = true;
my_cursor_mc.x = event.stageX;
my_cursor_mc.y = event.stageY;
}
function hide_cursor(event:Event):void
{
my_cursor_mc.visible=false;
}
i tried using this (below) but was very glichy and had to press button for cursor to go away THEN i was able to click on the button (not really ideal):
stage.addEventListener(MouseEvent.CLICK, hide_cursor);
Sounds like your cursor might be stealing the mouse events for your buttons. In your top level code (or constructor) try adding:
// Disable mouse events for cursor
my_cursor_mc.mouseEnabled = false;
If you mouse event has any child objects also add:
// Disable mouse events for any children of the cursor
my_cursor_mc.mouseChildren = false;
I'm trying to implement highcharts panning based on this example:
http://jsfiddle.net/HXUmK/5/
But I want to be able to zoom with the left mouse button and pan with the right mouse button. So I modified the code above and managed to make it work a little, but when I pan holding the right mouse button, the charts also zoomes.
Is there a way I can disable right mouse button zooming in highcharts?
Edit: Sorry for not being very clear about it. The code in the jsfiddle is not my code. Forget that code, it's just an example form witch I started. I am trying to modify that code in order to get left button zoom and right button pan. So I disabled the mousewheel zoom and activated the standars highcharts zoom
Edit2: Here is my code: http://jsfiddle.net/TKPQN/
You can try with selection event:
chart: {
...
events:{
selection: function(event) {
if (lastButton == 1)
event.preventDefault();
}
}
}
See http://jsfiddle.net/TKPQN/48/
I've wanted to use the Shift key for zooming, so this is my solution
$('#container').highcharts('StockChart', {
chart: {
//zoomType: 'x', // we declare it without zoom, so the pan is enabled
// ...
}});
var chart = $('#container').highcharts();
chart.pointer.cmd = chart.pointer.onContainerMouseDown;
chart.pointer.onContainerMouseDown = function (a){
//in my case, I need only X zooming, so I enable it if shift is pressed
this.zoomX=this.zoomHor=this.hasZoom=a.shiftKey;
this.cmd(a);
};
seems to work ok, so hope it help you
here is a JSFiddle working example: http://jsfiddle.net/73bc23zq/