1    def try_get_clip_rect (control : Control) =
2        if control is TextBox
3           || control is MultilineTextBox
4           || control is Scroller
5           || control is ScissorControl
6        then
7            let global_pos = control.global_position
8            let x = global_pos.x.max 0
9            let y = global_pos.y.max 0
10           let w = control.width as f32 + global_pos.x - x |> as<u32>
11           let h = control.height as f32 + global_pos.y - y |> as<u32>
12           Rect x.as<i32> y.as<i32> w h |> Some
13       else
14           None
15