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: Accept / Cancel action decoration  (Read 9635 times)
Stephen T.
Posts: 114


« on: November 19, 2015, 05:34:03 pm »

Is there a way now or planned to simply modify the decoration (text/image) on an action? (A DIALOG class call?)

Most actions are fine as defined in a 4ad, but (and maybe this is just me) the accept and cancel buttons take on different guises. in some cases the accept means 'Select' and then could mean 'Save' or 'OK' - similarly, cancel can be 'Back', 'Exit', 'Abort', 'Cancel' etc.
Reuben B.
Four Js
Posts: 1047


« Reply #1 on: November 20, 2015, 04:34:23 am »

In the 3.0 EAP which is underway now, I have not seen you posting in there, you can override the ACTION attributes in your 4gl.  In one of my samples, I have something like ... ON ACTION accept ATTRIBUTES(TEXT="Search") for use in a CONSTRUCT statement.

Otherwise prior to 3.0 you might be able to achieve what you want via DOM tree manipulation.

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

... its not perfect as from memory it doesn't necessarily propagate out to action views ie you had to change button, toolbar, topmenu items manually as well, whereas if I was able to persuade developers to add ui.Dialog.setText, ui.Dialog.setComment then I'd expect those methods to do that.

Reuben

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


« Reply #2 on: November 20, 2015, 09:59:00 am »

Reuben,
No, apologies for not signing up to the 3 EAP, but I haven't been able to dedicate time recently and am still trying to really catch up with changes in 2!
We (royal) have had a dom manipulator since the 1.10 days (I think!) - that is what prompted me - in the multi dialog that I'm using to test features, I still had to use that manipulator to change toolbar entries - and I just wondered if I'd missed a new feature.

I like the new stuff so far though - the ability to 'sub dialog' would have saved a bit of effort in the past. Good stuff.
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines