• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1149
  • Last Modified:

ITEMCHANGED EVENTS DOES NOT FIRE.

Powerbuilder 7

Window Name       : w_employee
Datawindow control: dw_master,    dataobject: dw_employee
Datawindow control: dw_tab1,        dataobject: dw_emp_admin
Datawindow control: dw_tab2,        dataobject: dw_emp_leave
Datawindow control: dw_tab3,        dataobject: dw_emp_pay_det

User Object: Uo_toolbar   ( with few command buttons)

In the itemchanged event I am doing something for e.g.

ls_emp_status   = tab_1.tabpage_1.dw_tab1.getitemstring(ll_tab1row, "emp_status")
ls_shift_nature = tab_1.tabpage_2.dw_tab2.getitemstring(ll_tab2row, "shift_nature")
ll_index_pay    = tab_1.tabpage_3.dw_tab3.getitemnumber(ll_tab3row,"index_pay")
etc

PROBLEM:

If any data is entered into any column in any of the above dws, and tab key is not pressed, then if any button of uo_toolbar (say save button) is clicked, THE ITEMCHANGED EVENT WILL NOT FIRE.

 I WANT ITEMCHANGED EVENTS TO FIRE IN SUCH CASE, AND IF ITEMCHANGED EVENTS RETURN ERROR THEN THE CURSOR SHOULD REMAIN WHERE IT WAS BEFORE CLICKING ANY BUTTON OF UO_TOOLBAR.

0
Mateen
Asked:
Mateen
  • 3
  • 3
1 Solution
 
diasroshanCommented:
Hi,

in the code of ur buttons for uo_toolbar write the following lines...

tab_1.tabpage_1.dw_tab1.AcceptText()
tab_1.tabpage_2.dw_tab2.AcceptText()
tab_1.tabpage_3.dw_tab3.AcceptText()

Acceptext() will fire ur itemchanged events...

Cheers,
Rosh
0
 
MateenAuthor Commented:

uo_toolbar actually u_toolbar_double is inherited

//////////////////////////////////////////////////////////////////////////
$PBExportHeader$u_toolbar_double.sru
forward
global type u_toolbar_double from userobject
end type
type pb_post from picturebutton within u_toolbar_double
end type
type pb_last from picturebutton within u_toolbar_double
end type
type pb_first from picturebutton within u_toolbar_double
end type
type pb_find from picturebutton within u_toolbar_double
end type
type pb_prev from picturebutton within u_toolbar_double
end type
type pb_next from picturebutton within u_toolbar_double
end type
type pb_save from picturebutton within u_toolbar_double
end type
type pb_delete from picturebutton within u_toolbar_double
end type
type pb_exit from picturebutton within u_toolbar_double
end type
type pb_new from picturebutton within u_toolbar_double
end type
end forward

global type u_toolbar_double from userobject
integer width = 2007
integer height = 152
boolean border = true
long backcolor = 67108864
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
event ue_new pbm_custom01
event ue_delete pbm_custom02
event ue_update pbm_custom03
event ue_retrieve pbm_custom04
event ue_next pbm_custom05
event ue_prev pbm_custom06
event ue_exit pbm_custom07
event ue_help pbm_custom08
event ue_first pbm_custom09
event ue_last pbm_custom10
event ue_find pbm_custom11
event ue_save pbm_custom12
event ue_del pbm_custom13
event ue_submit_save pbm_custom14
event ue_post pbm_custom15
event ue_bf_submit_save pbm_custom16
pb_post pb_post
pb_last pb_last
pb_first pb_first
pb_find pb_find
pb_prev pb_prev
pb_next pb_next
pb_save pb_save
pb_delete pb_delete
pb_exit pb_exit
pb_new pb_new
end type
global u_toolbar_double u_toolbar_double

forward prototypes
public subroutine bf_item_enable_desiable (string ra_botton_stat)
end prototypes

event ue_new;parent.TriggerEvent("ue_new")
end event

event ue_delete;parent.TriggerEvent("ue_delete")
end event

event ue_update;parent.TriggerEvent("ue_update")

end event

event ue_retrieve;parent.TriggerEvent("ue_retrieve")

pb_prev.Enabled=TRUE
pb_next.Enabled=TRUE
end event

event ue_next;parent.TriggerEvent("ue_next")
end event

event ue_prev;parent.TriggerEvent("ue_prev")
end event

event ue_exit;parent.triggerevent("ue_exit")
end event

event ue_help;Parent.TriggerEvent("ue_help")
end event

event ue_first;parent.TriggerEvent("ue_first")
end event

event ue_last;parent.TriggerEvent("ue_last")
end event

event ue_find;parent.triggerevent("ue_find")
end event

event ue_save;parent.TriggerEvent("ue_save")
end event

event ue_del;parent.TriggerEvent("ue_del")
end event

event ue_post;parent.TriggerEvent("ue_post")
end event

event ue_bf_submit_save;parent.TriggerEvent("ue_bf_submit_save")
end event

public subroutine bf_item_enable_desiable (string ra_botton_stat);if ra_botton_stat='Insert' then
      pb_delete.Enabled =false
      pb_find.Enabled   =true
      pb_first.Enabled  =false
      pb_next.Enabled   =false
      pb_prev.Enabled   =false
      pb_last.Enabled   =false
      pb_save.Enabled   =true
end if

if ra_botton_stat='Query' then
      pb_new.Enabled    =false
      pb_delete.Enabled =false
      pb_first.Enabled  =false
      pb_next.Enabled   =false
      pb_prev.Enabled   =false
      pb_last.Enabled   =false
      pb_save.Enabled   =false
end if

if ra_botton_stat='Ret' or ra_botton_stat = 'edit' then
      pb_new.Enabled    =true
      pb_delete.Enabled =true
      pb_first.Enabled  =true
      pb_next.Enabled   =true
      pb_prev.Enabled   =true
      pb_last.Enabled   =true
      pb_save.Enabled   =true
end if

end subroutine

on u_toolbar_double.create
this.pb_post=create pb_post
this.pb_last=create pb_last
this.pb_first=create pb_first
this.pb_find=create pb_find
this.pb_prev=create pb_prev
this.pb_next=create pb_next
this.pb_save=create pb_save
this.pb_delete=create pb_delete
this.pb_exit=create pb_exit
this.pb_new=create pb_new
this.Control[]={this.pb_post,&
this.pb_last,&
this.pb_first,&
this.pb_find,&
this.pb_prev,&
this.pb_next,&
this.pb_save,&
this.pb_delete,&
this.pb_exit,&
this.pb_new}
end on

on u_toolbar_double.destroy
destroy(this.pb_post)
destroy(this.pb_last)
destroy(this.pb_first)
destroy(this.pb_find)
destroy(this.pb_prev)
destroy(this.pb_next)
destroy(this.pb_save)
destroy(this.pb_delete)
destroy(this.pb_exit)
destroy(this.pb_new)
end on

type pb_post from picturebutton within u_toolbar_double
event clicked pbm_bnclicked
integer x = 1792
integer y = 12
integer width = 197
integer height = 120
integer taborder = 71
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "Post"
alignment htextalign = left!
end type

event clicked;parent.TriggerEvent("ue_post")
end event

type pb_last from picturebutton within u_toolbar_double
string tag = "Last"
integer x = 1202
integer y = 12
integer width = 197
integer height = 120
integer taborder = 60
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
boolean enabled = false
string text = "&Last"
end type

event clicked;parent.TriggerEvent("ue_last")
end event

type pb_first from picturebutton within u_toolbar_double
event clicked pbm_bnclicked
string tag = "First"
integer x = 613
integer y = 12
integer width = 197
integer height = 120
integer taborder = 80
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
boolean enabled = false
string text = "&First"
alignment htextalign = left!
end type

event clicked;parent.TriggerEvent("ue_first")
end event

type pb_find from picturebutton within u_toolbar_double
string tag = "Find"
integer x = 416
integer y = 12
integer width = 197
integer height = 120
integer taborder = 90
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "&Query"
end type

event clicked;
if pb_find.text = '&Query' then
      bf_item_enable_desiable('Query')
else
      bf_item_enable_desiable('Ret')

end if
parent.TriggerEvent("ue_find")
end event

type pb_prev from picturebutton within u_toolbar_double
string tag = "Prev"
integer x = 809
integer y = 12
integer width = 197
integer height = 120
integer taborder = 50
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
boolean enabled = false
string text = "&Prev"
alignment htextalign = left!
end type

event clicked;parent.TriggerEvent("ue_prev")
end event

type pb_next from picturebutton within u_toolbar_double
string tag = "Next"
integer x = 1006
integer y = 12
integer width = 197
integer height = 120
integer taborder = 40
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
boolean enabled = false
string text = "&Next"
alignment htextalign = left!
end type

event clicked;parent.TriggerEvent("ue_next")
end event

type pb_save from picturebutton within u_toolbar_double
string tag = "Save"
integer x = 1399
integer y = 12
integer width = 197
integer height = 120
integer taborder = 30
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "&Save"
end type

event clicked;parent.TriggerEvent("ue_bf_submit_save")

end event

type pb_delete from picturebutton within u_toolbar_double
string tag = "Delete"
integer x = 219
integer y = 12
integer width = 197
integer height = 120
integer taborder = 20
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
boolean enabled = false
string text = "&Del"
end type

event clicked;parent.TriggerEvent("ue_del")
 
end event

type pb_exit from picturebutton within u_toolbar_double
integer x = 1586
integer y = 12
integer width = 197
integer height = 120
integer taborder = 70
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "&Exit"
string picturename = "bye.bmp"
alignment htextalign = left!
end type

event clicked;      parent.TriggerEvent("ue_exit")
end event

type pb_new from picturebutton within u_toolbar_double
string tag = "Add"
integer x = 23
integer y = 12
integer width = 197
integer height = 120
integer taborder = 10
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "&New"
end type

event clicked;bf_item_enable_desiable('Insert')
parent.TriggerEvent("ue_new")
end event
//////////////////////////////////////////////////////////////////////////


Hi rosh,

Is this a case, which should be controlled by loose focus and get focus event?
If so, your expertise could design the proper code.
 


0
 
diasroshanCommented:
Hi,

it is a normal practise to write accepttext in ur code in almost all events where u wud require value from ur datawindow... once uve entered value in the last column of ur DW and dont press tab the value remains in the edit control and not applied to the buffer... so accepttext is important...

so what u need to do is write the following code in the button clicked events of all ur buttons...
tab_1.tabpage_1.dw_tab1.AcceptText()
tab_1.tabpage_2.dw_tab2.AcceptText()
tab_1.tabpage_3.dw_tab3.AcceptText()




Cheers,
Rosh

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
MateenAuthor Commented:
Ok,
I would go as u suggest.

Actually , Now I see, that in my save event, I have already writen

ll_tab1row =  tab_1.tabpage_1.dw_tab1.getrow()
ll_tab2row =  tab_1.tabpage_2.dw_tab2.getrow()
ll_tab3row =  tab_1.tabpage_3.dw_tab3.getrow()
dw_master.accepttext()
tab_1.tabpage_1.dw_tab1.AcceptText()
tab_1.tabpage_2.dw_tab2.AcceptText()
tab_1.tabpage_3.dw_tab3.AcceptText()

Despite this, something seems to be wrong ( specially current row number).

I would like to try myself to find where I am wrong.

Please wait

I would come back to u, if help needed.

Regards
0
 
MateenAuthor Commented:
There was a problem of instance variable in my application. When changed with local variable, everything became ok.

There is no way to put any amount of money for what I learn from U and EE

Regards

Mateen
0
 
diasroshanCommented:
Hi,

Thanx pal!!!

All the best and Cheers... ;)

Rosh
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now