Here's how I would accomplish #1:
extends ScrollContainer
const SCROLL_MARGIN = 16 # Unit: px
# Choose a multiple of 60 to prevent stuttering on 60Hz displays.
const SCROLL_SPEED = 120 # Unit: px/sec
onready var scroll_horizontal_float = float(scroll_horizontal) # Unit: px
func _process(delta):
var mouse_pos = get_local_mouse_position()
if is_in_range(mouse_pos.y, 0, rect_size.y):
if is_in_range(mouse_pos.x, 0, SCROLL_MARGIN):
scroll_horizontal_float -= SCROLL_SPEED * delta
elif is_in_range(mouse_pos.x, rect_size.x - SCROLL_MARGIN, rect_size.x):
scroll_horizontal_float += SCROLL_SPEED * delta
scroll_horizontal = int(round(scroll_horizontal_float))
func is_in_range(value, lower_bound, upper_bound):
return lower_bound <= value and value <= upper_bound