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
c545a6e3
Unverified
Commit
c545a6e3
authored
1 year ago
by
StaffEngineer
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #14 from StaffEngineer/minor
show how to get text widget
parents
c785faee
1d8e9dba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/basic_ui.rs
+17
-2
17 additions, 2 deletions
examples/basic_ui.rs
with
17 additions
and
2 deletions
examples/basic_ui.rs
+
17
−
2
View file @
c545a6e3
use
bevy
::{
core_pipeline
::
clear_color
::
ClearColorConfig
,
prelude
::
*
,
window
::
PrimaryWindow
};
use
bevy_cosmic_edit
::{
ActiveEditor
,
CosmicAttrs
,
CosmicEditPlugin
,
CosmicEditUiBundle
,
Cosmic
FontConfig
,
CosmicFontSystem
,
CosmicMetrics
,
CosmicText
,
CosmicTextPosition
,
ActiveEditor
,
CosmicAttrs
,
CosmicEditPlugin
,
CosmicEditUiBundle
,
Cosmic
Editor
,
CosmicFontConfig
,
CosmicFontSystem
,
CosmicMetrics
,
CosmicText
,
CosmicTextPosition
,
};
use
cosmic_text
::
AttrsOwned
;
...
...
@@ -53,6 +53,20 @@ fn setup(
});
}
fn
print_text
(
text_inputs_q
:
Query
<&
CosmicEditor
,
With
<
CosmicEditor
>>
,
mut
previous_value
:
Local
<
String
>
,
)
{
for
text_input
in
text_inputs_q
.iter
()
{
let
current_text
=
text_input
.get_text
();
if
current_text
==
*
previous_value
{
return
;
}
*
previous_value
=
current_text
.clone
();
info!
(
"Widget text: {}"
,
current_text
);
}
}
fn
main
()
{
let
font_bytes
:
&
[
u8
]
=
include_bytes!
(
"../assets/fonts/VictorMono-Regular.ttf"
);
let
font_config
=
CosmicFontConfig
{
...
...
@@ -65,5 +79,6 @@ fn main() {
.add_plugins
(
DefaultPlugins
)
.add_plugins
(
CosmicEditPlugin
{
font_config
})
.add_systems
(
Startup
,
setup
)
.add_systems
(
Update
,
print_text
)
.run
();
}
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