Otherwise we end up with outdated pre-edit data if we change focus while
editing.
Note: Qt doas actually send a "commit" event when the focus change
(but of course that does not happen when changing the focus within
slint)
But firefox does discard the preedit when loosing the focus.
CC #1925
This will be needed for embedding - to avoid creating two window
adapters - and it will be needed for the API to allow creating a
component from an existing window.
When the TextInput item is read-only, it should not report availability
or any other status to the input method via the window adapter.
This also fixes the order of events when clicking on a TextInput: We
would send the ime position update request before enabling the ime,
because we set the focus _after_ setting the cursor pos.
Fixes#2812
In the compiler this is still very primitive, but an attempt to start a
generic interface. The basic assumption is that all item functions will
eventually need access to the window adapter and itemrc. Support for
additional arguments is still missing.
Also missing is support for the function access via rtti in the
interpreter, hence the hardcoding at the moment.
Make text_input_byte_offset_for_position and text_input_cursor_rect_for_byte_offset
low-level in the API, where the implementation becomes easier. Two
helper functions in TextInput in turn collect the necessary parameters
and thus also reduce the amount of duplicated code.
This also decouples the renderer further from the window.
So that we don't need to query the geometry multiple time, and this pave
the way to not have the geometry in the items
Part of #1932
As a drive by, fix the clipping of the Path element which incorrectly
offseted the clip by (x,y).
Similar fixes happen in the Clip element in some renderer, but that
didn't have effect because x and y are always 0 for the Clip element
When scrolling the printer demo, I often end up closing or opening
element i don't want to because we reached the end and therefore it is
not scrolling and forwarding the event
Return the path events for rendering as an Option, so that if the path is empty,
we simply return.
This avoids a double property dependency in the (likely) event the path is not empty.
Instead of the ClippedImage. Because we use the colorize property more
often than the source property, and these are soon going to be even more
expensive
We need to continue propagating the release event to other element (eg
other flickable)
Fix the flickable flicking even though the mouse is released if there are
several Flickable in the component.
Olivier found the following steps that reproduce the crash with Skia:
1. Open the gallery and select the "Text Edit" tab.
2. In the first text edit widget, select the first three letters.
3. Click into the second text edit (while the first one shows the selected text)
4. At the beginning of the text, insert the letter "ù" a few times.
This sequence would result in the cursor_position property get out of
sync. Since it represents a byte offset in the utf-8 text, it would
point straight into a utf-8 sequence, resulting in a panic when the
renderer would try to create a slice of the selected text.
As a remedy, this patch renames the cursor_position and anchor_position
properties and provides wrapper getter accessors for use within the
TextInput to safely bound the stored offset.
Eventually we need to intercept changes to the text property and adjust
the cursor and anchor position properties accordingly, so that they
remain valid. However this requires that the compiler is aware that a
property is not accessible directly but has a setter that needs to be
called instead.
This likely/hopefully also fixes#1707.
We already checked before that we can flick in that direction
(horizontally or vertically), but we did not check that we were not
actually at the end already.
This removes the special code for the generated property getters and
ensures type safety in the run-time library for property value setting.
In the Rust generated code we continue to do arithmetic on the scalar
values, that means we immediately extract the scalar, do arithmetic and
rely on the compiler to only allow compatible units.
Danger zone alert: In the interpreter Value::Number can now be converted
to LogicalLength as-is.