mirror of
https://github.com/danbulant/cushy
synced 2026-06-15 04:21:06 +00:00
Fixing password field clicking
This commit is contained in:
parent
7992887a85
commit
ca58cb5fcf
2 changed files with 28 additions and 7 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -623,7 +623,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "figures"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/khonsulabs/figures#0745fc0ff95e94ce2181aa1528a30bda3d6152f2"
|
||||
source = "git+https://github.com/khonsulabs/figures#40045fa1940f6212bc4876a4ef9ae2cd0bd89808"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"euclid",
|
||||
|
|
@ -1089,7 +1089,7 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
|||
[[package]]
|
||||
name = "kludgine"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/khonsulabs/kludgine#f286d7de3f37ec7430890f6eeeb5d98a1ff0314e"
|
||||
source = "git+https://github.com/khonsulabs/kludgine#6b56d6524a8843f9a1a598e4d344407798971732"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"alot",
|
||||
|
|
|
|||
|
|
@ -496,8 +496,10 @@ where
|
|||
if mask_bytes > 0 {
|
||||
self.value.map_ref(|value| {
|
||||
let value = value.as_str();
|
||||
assert!(cursor.offset <= value.len());
|
||||
cursor.offset = value[..cursor.offset].graphemes(true).count() * mask_bytes;
|
||||
if let Some(selection) = &mut selection {
|
||||
assert!(selection.offset <= value.len());
|
||||
selection.offset =
|
||||
value[..selection.offset].graphemes(true).count() * mask_bytes;
|
||||
}
|
||||
|
|
@ -652,18 +654,37 @@ where
|
|||
&mut self,
|
||||
location: Point<Px>,
|
||||
context: &mut EventContext<'_, '_>,
|
||||
) -> Cursor {
|
||||
let mut cursor = self.cached_cursor_from_point(location, context);
|
||||
if let Some(symbol) = self.mask.graphemes(true).next() {
|
||||
let grapheme_offset = cursor.offset / symbol.len();
|
||||
cursor.offset = self.value.map_ref(|value| {
|
||||
value
|
||||
.as_str()
|
||||
.graphemes(true)
|
||||
.take(grapheme_offset)
|
||||
.map(str::len)
|
||||
.sum::<usize>()
|
||||
});
|
||||
}
|
||||
cursor
|
||||
}
|
||||
|
||||
fn cached_cursor_from_point(
|
||||
&mut self,
|
||||
location: Point<Px>,
|
||||
context: &mut EventContext<'_, '_>,
|
||||
) -> Cursor {
|
||||
let Some(cache) = &self.cache else {
|
||||
return Cursor::default();
|
||||
};
|
||||
|
||||
let text_length = self.value.map_ref(|value| value.as_str().len());
|
||||
let padding = context
|
||||
.get(&IntrinsicPadding)
|
||||
.into_px(context.kludgine.scale());
|
||||
let location = location - padding;
|
||||
let mut location = location - padding;
|
||||
if location.y < 0 {
|
||||
return Cursor::default();
|
||||
location.y = Px::ZERO;
|
||||
}
|
||||
|
||||
let mut closest: Option<(Cursor, i32)> = None;
|
||||
|
|
@ -686,7 +707,7 @@ where
|
|||
&& relative.y < cache.measured.line_height
|
||||
{
|
||||
return if relative.x > rect.size.width / 2 {
|
||||
if glyph.info.start + 1 < text_length {
|
||||
if glyph.info.start + 1 < cache.bytes {
|
||||
Cursor {
|
||||
offset: glyph.info.start + 1,
|
||||
affinity: Affinity::Before,
|
||||
|
|
@ -730,7 +751,7 @@ where
|
|||
closest
|
||||
} else {
|
||||
Cursor {
|
||||
offset: text_length,
|
||||
offset: cache.bytes,
|
||||
affinity: Affinity::After,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue