Comment obtenir la position d'un texte dans un script

jlaurens shared this question 3 years ago
Answered

Bonjour,

J'ai un champ de texte dans une figure.

Dans le script d'un bouton, je souhaite créer un autre champ de texte temporaire, juste au dessous du premier, aligné à gauche.

Les deux champs doivent être en position absolue sur l'écran (le premier l'est déjà)

Je travaille en GGB5

Merci d'avance

Comments (9)

photo
1

Bonjour ,

une solution est d'attacher les deux textes à un même point .

Cordialement

photo
1

Bonjour,

Je ne sais pas exactement quel est le but de cette création temporaire, mais une solution pourrait être de créer un deuxième champ texte (permanent donc) et de l’afficher ou de le cacher suivant la situation, ce qui est simple à faire par script.

Cordialement,

Pierre

photo
1

Merci de ces suggestions, malheureusement aucune ne me convient:

@frndmrsl: attacher un texte à un point est incompatible avec la position fixe à l'écran. Dès qu'on "zoome", le point et le texte se dissocient

@Pierre Rubod : créer un deuxième texte a priori est bien si la hauteur du premier texte ne change pas, mais ce n'est pas mon cas.

Je vais essayer de changer le contenu du premier texte.

photo
1

@frndmrsl: attacher un texte à un point est incompatible avec la position fixe à l'écran. Dès qu'on "zoome", le point et le texte se dissocient 

use B=attachcopytoview(A,1) and fix the position of text to B; so you can get the position of text with corner(text, ) after zoom for fixing another text

photo
photo
1

C'est un peu compliqué mais on peut inhiber la possibilité de zoomer , ce qui peut être très intéressant dans certaines applications .

photo
1

Changer le contenu du premier texte comme envisagé semble donner satisfaction

photo
1

Une autre solution pourrait être d'ajouter une variable de texte à la fin du texte fixe.

Cette variable de texte est remplie par un script avec un texte, ou une chaîne vide.

photo
1

sorry but what it is: SetValue (texte2, no empty B)


no empty [B], no empty [A]. A and B?

(scusa ma che cosa è: SetValue(texte2, no empty B)

no empty [B], no empty [A]. A e B?)

photo
1

By A and B I mean any other text.

I mean by no empty any text != ""

I mean by empty string the value ""

check the script inside the buttons, then I think it's more clear

.sorry for button-caption confused.

.

The sample demonstrate that you can expand a text in an absolut positioned text so the condition in the thread header are fulfilled. (I think).

This is much more easy then to create a second text-object at the correct position.

photo
© 2023 International GeoGebra Institute