Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bevy Cosmic Edit
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Forks
Bevy Cosmic Edit
Commits
adb639a5
Commit
adb639a5
authored
11 months ago
by
sam edelsten
Browse files
Options
Downloads
Patches
Plain Diff
add tag component to disable user selection
parent
d250f4c6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib.rs
+3
-0
3 additions, 0 deletions
src/lib.rs
src/user_select.rs
+21
-0
21 additions, 0 deletions
src/user_select.rs
with
24 additions
and
0 deletions
src/lib.rs
+
3
−
0
View file @
adb639a5
...
...
@@ -88,6 +88,7 @@ mod input;
mod
password
;
mod
placeholder
;
mod
render
;
mod
user_select
;
mod
util
;
mod
widget
;
...
...
@@ -109,6 +110,7 @@ pub use input::*;
pub
use
password
::
*
;
pub
use
placeholder
::
*
;
pub
use
render
::
*
;
pub
use
user_select
::
*
;
pub
use
util
::
*
;
pub
use
widget
::
*
;
...
...
@@ -132,6 +134,7 @@ impl Plugin for CosmicEditPlugin {
PlaceholderPlugin
,
PasswordPlugin
,
EventsPlugin
,
UserSelectPlugin
,
))
.insert_resource
(
CosmicFontSystem
(
font_system
));
...
...
This diff is collapsed.
Click to expand it.
src/user_select.rs
0 → 100644
+
21
−
0
View file @
adb639a5
use
crate
::
*
;
use
bevy
::
prelude
::
*
;
pub
(
crate
)
struct
UserSelectPlugin
;
impl
Plugin
for
UserSelectPlugin
{
fn
build
(
&
self
,
app
:
&
mut
App
)
{
app
.add_systems
(
Update
,
clear_selection
.after
(
InputSet
));
}
}
/// Tag component to disable user selection
/// Like CSS `user-select: none` https://developer.mozilla.org/en-US/docs/Web/CSS/user-select
#[derive(Component)]
pub
struct
UserSelectNone
;
fn
clear_selection
(
mut
q
:
Query
<&
mut
CosmicEditor
,
With
<
UserSelectNone
>>
)
{
for
mut
editor
in
q
.iter_mut
()
{
editor
.set_selection
(
cosmic_text
::
Selection
::
None
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment