mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
ohos: Support swiping to go back (#34433)
Override the `onBackPress` callback, which by default brings the application to the background and instead tell servo to go back one page. Users can invoke this by swiping from the left edge to the middle. There is no equivalent callback / gesture to go forward. In the default browser swiping from the right side to the middle also invokes the goBack callback. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
f2b5f515d7
commit
7489e3d5f4
1 changed files with 8 additions and 1 deletions
|
@ -67,6 +67,13 @@ struct Index {
|
|||
@LocalStorageProp('CommandlineArgs') CommandlineArgs: string = ""
|
||||
@State urlToLoad: string = this.InitialURI
|
||||
|
||||
// Called when the user swipes from the right or left edge to the middle
|
||||
// Default behavior is bringing the app to the background.
|
||||
onBackPress(): boolean | void {
|
||||
this.xComponentContext?.goBack()
|
||||
return true;
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
|
@ -76,7 +83,7 @@ struct Index {
|
|||
.width('12%')
|
||||
.fontSize(12)
|
||||
.onClick(()=>{
|
||||
this.xComponentContext?.goBack()
|
||||
this.onBackPress()
|
||||
})
|
||||
Button('⇨').backgroundColor(Color.White)
|
||||
.fontColor(Color.Black)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue