Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: change the text of an action default button  (Read 12737 times)
Stefan S.
Posts: 90


« on: June 15, 2010, 10:40:18 am »

Hello,
I define the action defaults in the per-File

action defaults
   action key_f7   (text= "F7 allg. Texte", accelerator=F7)
   action key_f8   (text= "F8 Lieferanschriften", accelerator=F8)
end

Now I want to change the text for the action key_f7 in my 4gl program.

I tried "setElementText", but this didn't work.

Has anyone an idea

Stefan
Leo S.
Four Js
Posts: 126


« Reply #1 on: June 15, 2010, 01:34:55 pm »

Hi Stefan, could you please explain in which situation the text should change?
Is it that you want to re use F7 in another context (that means the semantic of the action changes?)
So pressing F7 no longer shows general purpose text but does something else?

Kind Regards, Leo

Leo S.
Four Js
Posts: 126


« Reply #2 on: June 15, 2010, 02:27:04 pm »

Stefan,
If you don't insist on ON ACTION you can achieve what you want with some BDL compatible statements using ON KEY()
(I guess the primary focus is on having a well defined Function key order)
Paste the code below and tell me if this is what you were looking for
Kind Regards, Leo
--------------keylabel.4gl--------------
MAIN
  DEFINE a,b STRING
  OPEN FORM f FROM "keylabel"
  DISPLAY FORM f
  INPUT BY NAME a,b
    ON KEY(F7)
      IF INFIELD(a) THEN
        DISPLAY "F7 in a"
      ELSE
        DISPLAY "F7"
      END IF
    ON KEY(F8)
      IF INFIELD(b) THEN
        DISPLAY "F8 in b"
      ELSE
        DISPLAY "F8"
      END IF
  END INPUT
END MAIN
--------------keylabel.per--------------
LAYOUT
GRID
{
 a test input [a             ]
 b test input [b             ]
}   
END   
END     
ATTRIBUTES
a=FORMONLY.a,KEY F7="F7 Text in a";
b=FORMONLY.b,KEY F8="F8 Liefer in b";
   
INSTRUCTIONS
KEYS   
F7= "F7 allg. Texte"
F8= "F8 Lieferanschriften"
                   
Stefan S.
Posts: 90


« Reply #3 on: June 15, 2010, 03:31:36 pm »

Thanks,

the reason why I wnat to change the text is simple.
I have a form with 3 arrays.
From Array 1 I switch with "F7" to array 2 to see details und from array 2 I switch to array 3 to See some Text. But the User should only press F7 twice to switch between the arrays.

If  I have to work with "on key" instead of "on action" , then I can use fgl_setkeylabel ("F7", "F7 - Details").
We changed our program from "on action" back to "on key" and now it worked.

But it would be fine to have the posibility to change the action text


Stefan
Leo S.
Four Js
Posts: 126


« Reply #4 on: June 15, 2010, 03:52:57 pm »

May be you need to post some more code.
From your description I cannot deduce if you are using singular dialogs or a multiple dialog.
Since Multiple Dialogs are there you would be able to switch between arrays via the "Tab" key if you are willing to pack your array handling code into 1 DIALOG instruction (assuming the code for all 3 arrays is in 1 module).
In singular dialogs if you invoke a 2nd dialog in a chain you could load different action defaults for 1 and the same action.
I was assuming you need that in one and the same dialog.
Kind Regards, Leo
Bryce S.
Posts: 52


« Reply #5 on: June 16, 2010, 01:28:26 am »

Hi Stefan,

I have forms with several actions having the same accelerator. As long as only one of these actions is active you get the text you expect. eg:

ACTION insert_meeting ( TEXT="Add Meeting", image="plus", ACCELERATOR=F3, COMMENT="Add a new meeting" )
ACTION new_raceday ( TEXT="New Day", image="plus", ACCELERATOR=F3, COMMENT="Add a new raceday")


  but both actions are not referenced in the same input/display statement so only the correct text shows.
Does this do what you want?

Regards,
  Bryce Stenberg.
Reuben B.
Four Js
Posts: 1080


« Reply #6 on: June 16, 2010, 02:12:51 am »

The functions below should do what you are after.  They are from my auitree example on sourcefourjs http://code.google.com/p/sourcefourjs/wiki/auitree

Code
  1. ...
  2. INPUT ARRAY
  3.   BEFORE INPUT
  4.      CALL action_text_set("key_f7", "Details")
  5. ...
  6. ...
  7. INPUT ARRAY
  8.   BEFORE INPUT
  9.      CALL action_text_set("key_f7", "Text")
  10. ...
  11.  
  12.  
  13.  
  14. #+ action_text_set Change the text attribute of a given action
  15. FUNCTION action_text_set(action, text)
  16. DEFINE action, text STRING
  17. DEFINE n om.DomNode
  18.  
  19.   LET n = action_node_get(action)
  20.   IF n IS NOT NULL THEN
  21.      CALL n.setAttribute("text", text)
  22.   END IF
  23. END FUNCTION
  24.  
  25.  
  26. FUNCTION action_node_get(name)
  27. DEFINE name STRING
  28. DEFINE w ui.Window
  29. DEFINE n,f om.DomNode
  30. DEFINE nl om.nodeList
  31.  
  32.   LET w = ui.Window.getCurrent()
  33.   LET n = w.getNode()
  34.   LET nl = n.selectByPath(SFMT("//Action[@name=\"%1\"]",name))
  35.   IF nl.getLength() != 1 THEN
  36.      LET nl = n.selectByPath(SFMT("//MenuAction[@name=\"%1\"]",name))
  37.   END IF
  38.   IF nl.getLength() = 1 THEN
  39.      LET f=  nl.item(1)
  40.   END IF
  41.   RETURN f
  42. END FUNCTION

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Stefan S.
Posts: 90


« Reply #7 on: June 16, 2010, 10:24:32 am »

many thanks Reuben,

this is what I need.


Kind regards

Stefan

Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines