How to manage the Error Message Box Size shown when using ErrorFixer methods? - ewam

Image with large alert box
I have a situation where the alert box shown on the screen with the message is too large (default size). How to customize the size of the alert box?
Class: aWFErrorFixer
Method: AlertWithErrors
procedure AlertWithErrors(customMessage : CString)
if customMessage = ''
self.Message = mlTheFollowingErrorsHaveBeenRaised_
else
self.Message = customMessage
endIf
if self.Interact(self.Scenario.WFErrorFixerModal, Consultation, True) = rValid
endIf
endProc

Create a scenario in your aWFErrorFixer called WFErrorFixerMain:
In the code section of this scenario, the WFErrorFixerMainAgent would be a child of the aUIAgent. The aUIAgent has a method called ChangePos():
function InteractWithUser(ExecMode : tExecMode, IsModal : Boolean) return tResult override
self.ChangePos(4000, 4000, 100, 100)
return inherited self.InteractWithUser(ExecMode, IsModal)
endFunc

Related

PeopleCode error while trying to call function on Page PeopleCode event

I am trying to add the below function (populate_details) to a Page PeopleCode Activate event. The top section of code already exists, I am trying to add the section starting at 6/24/20 comments and getting the error "Syntax error: expecting statement. (2,42) ^ HCSC" If I remove the top section of the code then the error does not display and it saves properly, so I must have some sort of syntax error. Thanks for the help!
import HR_DIRECT_REPORTS:EmployeeSelection;
Component HR_DIRECT_REPORTS:EmployeeSelection &MyUI;
&MyUI.PageActivate();
/*GHS KLG - link to Footprints on termination screen*/
If DERIVED_HR_DR.HR_DR_PAGE_TITLE.Value = "Terminate Employee" Then
GHS_MSS_WRK.HTMLAREA.Value = MsgGetExplainText(31000, 27, "Message not found.");
GHS_MSS_WRK.HTMLAREA.Visible = True;
Else
GHS_MSS_WRK.HTMLAREA.Visible = False;
End-If;
/*GHS end*/
/* GHS KDR 6/24/20 BEGIN */
Declare Function populate_details PeopleCode GH_PERS_INF_WRK.FUNCLIB FieldFormula;
GH_PERS_INF_WRK.EFFDT = %Date;
populate_details(%Date, PERSON_NPC_VW.EMPLID.Value, GH_PERS_SRCH_CW.EMPL_RCD.Value);
/* GHS KDR 6/24/20 END */
You must declare your populate_details function at the top of the Page PeopleCode Activate event. Immediately after this line should work:
Component HR_DIRECT_REPORTS:EmployeeSelection &MyUI;
Then you can call your function as you did, the rest of the code looks fine.

Conditional classname and text (Rails)

I'm pretty new to Rails and trying some basic stuff like conditional classes.
On the 'show' view I have an element that changes styling depending on the stock availability, but also the text changes accordingly.
People keep saying the controller should be as small as possible, but placing this conditional in the view also feels dirty. Is this really the best way?
Current controller:
def show
#tyre = Tyres::Tyre.find_by_id(params[:id])
if #tyre.in_stock
#availability = I18n.t("products.filter.other.in_stock")
#availability_class = 'i-check-circle color--success'
else
#availability = I18n.t("products.filter.other.not_in_stock")
#availability_class = 'i-cross-circle color--important'
end
end
Edit:
Controller:
def show
#tyre = Tyres::Tyre.find_by_id(params[:id])
if #tyre.in_stock
#availability_append = ".in_stock"
else
#availability_append = ".not_in_stock"
end
#availability = I18n.t("products.filter.other#{#availability_append}")
end
View:
.xs-12.description__status
%i{class: (#tyre.in_stock? ? 'i-check-circle color--success' : 'i-cross-circle color--important')}
= #availability
You can clean your controller tyres_controller.rb (i suppose) method,
def show
#tyre = Tyre.find(params[:id]) # I believe you have a model named 'tyre'
end
Then, there will be a file named tyres_helper.rb in your myproject/app/helpers/. Put the following code there,
def tyre_availability(tyre) # it'll return an array with two values, first one is class name, second one is localized value
if tyre.in_stock
return 'i-check-circle color--success', I18n.t("products.filter.other.in_stock")
else
return 'i-cross-circle color--important', I18n.t("products.filter.other.not_in_stock")
end
end
and, in the view you can use,
.xs-12.description__status
%i{:class => tyre_availability(#tyre)[0]}
= tyre_availability(#tyre)[1]

How can I remove onEvent from button widget in Corona?

I am trying to remove onEvent listener from button widget. I tried to assign nil to onEvent attribute but it didn't work and lastly I tried this:
buttonWidget : removeEventListener("touch", buttonWidget.onEvent)
I have several button like that and it just stopped all button's event listeners. What do you suggest? How can I remove the event listener for one button widget? Thanks.
Here is how I create my button widgets:
for i=0,2 do
for j=0,8 do
count=count+1
letterBtn[count] = widget.newButton{
id = alphabet[count],
left = 5+j*50,
top = H-160+i*50,
label = alphabet[count],
width = 45,
height = 45,
font = nil,
fontSize = 18,
labelColor = { default = {0,0,0}, over = {255,255,255}},
onEvent = btnOnEventHandler
};
end
end
Can you tell me how can I remove onEvent later?
Okey, I tried Button: setEnabled(false) but still it disables all buttons not just one. I already tried your second advice but it gives the same result. I am copying the rest of the code. Can you please look at it and tell me what I am missing?
local function checkLetter(e)
if(guessWord) then
for i=1, #guessWord do
local c = guessWord:sub(i,i)
if c==e.target.id then
letter[i].text = e.target.id
letterCount = letterCount +1
print("letterCount"..letterCount)
e.target:setEnabled(false)
end
end
if (letterCount == #guessWord and not hanged) then
timer.performWithDelay(500, function()
letterCount=0
rightWGuess = rightWGuess+1
for k,v in pairs(notGuessedWord) do
if v == guessWord then
notGuessedWord[k]=nil
end
end
enableButtons()
startGame() end ,1)
end
end
end
local function btnOnEventHandler(e)
if(e.phase == "began") then
checkLetter(e)
print(e.target.id)
end
return true
end
If you want to temporarily (or permanently) stop a button from responding to touch events, you can use Button:setEnabled(false).
The following worked for me for removing a listener from just 2 buttons. Button 1 and 3 stopped responding to events as expected while 2, 4, and 5 still did.
Update: To disable, you have to do it on the 'ended' phase or Corona gets confused.
widget = require 'widget'
local function btnOnEventHandler(event)
print('Event', event.target.id, event.phase)
if event.phase == 'ended' then
-- Disable the button so it can't be clicked again
-- Must disable in the end state or Corona gets
-- confused
event.target:setEnabled(false)
end
end
local buttons = {}
for i=1,5 do
buttons[i] = widget.newButton{
id = 'button' .. i,
left = display.contentCenterX - 50,
top = 60 * i,
label = 'Button ' .. i,
width = 100,
height = 50,
onEvent = btnOnEventHandler
}
end
buttons[1]:removeEventListener('touch', buttons[1].onEvent)
buttons[3]:removeEventListener('touch', buttons[3].onEvent)

calling an event on a Button in datawindow

I have placed a search button on a datawindow, and i have already an event for searching such list...how is it possible to call an event once the button is clicked on runtime.
below is the code on my event named "ue_key"
string xcode, iseries, ycode, sql_statement, xname, i_cname, name, iseries_no, irequested_by, irequest_problem, irequesting_dept, idate_request, idate_needed
string iasset_no, idate_received, istatus
long i_row
//integer
i_cname = dw_work_order.getcolumnname()
i_row = this.getrow()
if i_row > 0 then
if key = keyF2! and i_cname = 'series_no' then
//open(w_csearch)
// Then, define select statement
sql_statement = "SELECT series_no as 'Series NO', requested_by as 'Requested By' FROM work_order_form where status = 'A' or status = 'ACTIVE';"
str_sellist args
args.trans = sqlca
args.sel_cmd = sql_statement
// Specify which column will be the return value
args.retcol = 1
// Define drop-down items. NOTE: This should correspond
// with the alias you use for the columns you retrieve
args.dropdown_items[1] = "Series NO"
args.dropdown_items[2] = "Requested By"
// Define Search Window Title
args.title = "Work Order"
// Define transaction object for the window
// This is REQUIRE for now... :)
// Open with parameter
OpenWithParm(w_sellist, args)
ycode=message.stringparm
xcode = ycode
// MessageBox('test', xcode)
if trim(xcode) <> '' then
select series_no, requested_by, request_problem, requesting_dept, date_request,date_needed, asset_no, status
into :iseries, :irequested_by, :irequest_problem, :irequesting_dept, :idate_request, :idate_needed, :iasset_no, :istatus
From work_order_form where series_no = :xcode using sqlca;
// Messagebox('test', iseries)
this.setitem(THIS.GETROW(),'series_no', iseries)
this.setitem(THIS.GETROW(),'requested_by', irequested_by)
this.setitem(THIS.GETROW(),'request_problem', irequest_problem)
this.setitem(THIS.GETROW(),'requesting_dept', irequesting_dept)
this.setitem(THIS.GETROW(),'date_request', idate_request)
this.setitem(THIS.GETROW(),'date_needed', idate_needed)
this.setitem(THIS.GETROW(),'asset_no', iasset_no)
this.setitem(THIS.GETROW(),'status', istatus)
//dw_work_order.retrieve(iseries)
end if
end if
end if
Thanks a lot!
The datawindow control has "ButtonClicking" and "ButtonClicked" events. You can use these event to identify which button was clicked (check the event arguments, specifically dwo.Name) and call the appropriate code.
You'll want to make sure that your datawindow button's action is set for "User Defined (0)".

How to override delete-event in pygtk?

I am coding a simple text editor, so I am trying to check unsaved changes before closing the application. Now I know it has to be something with 'delete-event', and by googling around I have found a way, but it gives an error.
This is my code:
__gsignals__ = {
"delete-event" : "override"
}
def do_delete(self, widget, event):
print 'event overriden'
tabsNumber = self.handler.tabbar.get_n_pages()
#self.handler.tabbar.set_current_page(0)
for i in range(tabsNumber, 0):
doc = self.handler.tabbar.docs[i]
lines = self.handler.tabbar.lineNumbers[i]
self.handler.tabbar.close_tab(doc, lines)
# if self.handler.tabbar.get_n_pages() == 0:
# self.destroy_app()
def destroy_app(self):
gtk.main_quit()
And this is the error I get:
TypeError: Gtk.Widget.delete_event() argument 1 must be gtk.Widget, not gtk.gdk.Event
What is the right way to do it?
I found the answer,
self.connect('delete-event', self.on_delete_event)
and
__gsignals__ = {
"delete-event" : "override"
}
def on_delete_event(event, self, widget):
tabsNumber = self.handler.tabbar.get_n_pages()
#self.handler.tabbar.set_current_page(0)
for i in range(tabsNumber, 0):
doc = self.handler.tabbar.docs[i]
lines = self.handler.tabbar.lineNumbers[i]
self.handler.tabbar.close_tab(doc, lines)
self.hide()
self.destroy_app()
return True
The key is in return True. It prevents the default handler to take place and for somehow the error doesn't appear any more.

Resources